Click here to Skip to main content
Email Password   helpLost your password?
  • Download demo project - 372 Kb
  • Download source files - 14 Kb
  • Sample Image - DigiStatic.gif

    Overview

    This article presents a CStatic derived class for displaying numbers or text like a LED Display. This control does not use bitmaps. Everything is drawn with lines and Bezier curves. First I made some classes to draw a character, which consists of segments that can be any closed shape, by only giving some points. The points can be connected by lines or by Bezier curves to make nice smoothened characters. The theory of fitting Bezier curves can be found in bezdist.pdf, created by Jim Fitzsimmons, in my demo project cabinet. The CDigiStatic resizes itself automatically, which can be experienced with the demo app, wherefore I used the resizing dialog code from Hans Bühler.

    To design the characters I looked around for different styles. The best inspiration came out of my car. I used characters from the date/time/temperature display and from my RDS-radio. 14- and 7-segment displays in straight and smooth style are supported and one common character for displaying a decimal point or a colon. I changed the designs a lot to get aesthetically best results, but I didn't go crazy by changing all the points every time because I do some nifty mirroring for most of the segments. For example I only specified 5 segments for the 14 segment display.

    The demo application shows all possibilities of this control.

    Overview of possible Characters

    7-segment straight 7-segment smooth 14-segment straight 14-segment smootht Colon and decimal point

    These are normalized characters with all segments turned on in all styles. The coordinates of these pictures were used to find the corners and Bezier points. You can adjust the coordinates or dimensions if you like. Then you can take them over to the source the same way as I did. The height of every design is the same only the width may be different, necessary for easy scaling.

    Public Functions

    SetText

    void SetText(LPCTSTR lpszText);

    Call this function to set the text of the control. For more info see SetDrawImmediately()

    Format

    void Format(LPCTSTR lpszFormat, ...);
    void Format( UINT nFormatID, ... );

    Call this member function to write formatted data to a CDigiStatic in the same way that sprintf formats data into a C-style character array. This function formats and stores a series of characters and values in the CDigiStatic. Each optional argument (if any) is converted and output according to the corresponding format specification in lpszFormat or from the string resource identified by nFormatID.

    SetColor

    void SetColor(COLORREF OffColor, COLORREF OnColor);

    Sets the on and off color of the segments of the CDigiStatic control. Segments that are off will not be painted when the DS_NO_OFF style is used.

    GetOnColor

    COLORREF GetOnColor() const

    Call this member function to retrieve the color that is used to indicate the segment is on

    GetOffColor

    COLORREF GetOffColor() const

    Call this member function to retrieve the color that is used to indicate the segment is off

    SetDrawImmediately

    void SetDrawImmediately(BOOL Enable = TRUE);

    If Enable set to TRUE a call to SetText() or Format() will redraw the window before the function returns. If Enable set to FALSE (the default of CDigiStatic) the client area is marked for painting when the next WM_PAINT message occurs.

    SetBkColor

    COLORREF SetBkColor(COLORREF BackColor = BLACK);

    Sets the current background color to the specified color and returns the previous background color. The value of the background color will be ignored when Transparency mode is enabled.

    SetTransparent

    void SetTransparent(BOOL bSet = TRUE);

    Set to TRUE only the segments will be drawn and the background will be transparent and show the window underneath it. Nice if you use a skinned window. Set to FALSE will fill the background with the current background color.

    ModifyDigiStyle

    BOOL ModifyDigiStyle(DWORD dwRemove, DWORD dwAdd);

    With the ModifyDigiStyle function you can add or remove specific CDigiStatic styles. The styles, which can be combined by using the bitwise OR ( | ) operator, are:

    How to use (in a dialog):

    1. Add digistatic.h, digistatic.cpp, memdc.h, curvefit.h, curvefit.cpp and rgbcolor.h to your project environment.
    2. Add a static control to your dialog resource.
    3. Change its ID to something like IDC_LEDTEXT, open class-wizard and assign a member variable, type control (CStatic) to it (m_LedText for example).
    4. Open your dialog class's header file. Add #include "digistatic.h". Find the line CStatic m_LedText and replace the CStatic by CDigiStatic.
    5. In OnInitDialog() you can give it some text with SetText(), change the colors with SetColor() or for the background SetBkColor(). Or, you can set the right style with ModifyDigistyle().
    6. Compile and run.

    Acknowledgements

    History

    Version Comments
    1.0 February 2000 First release version. Finally I could say goodbye to my old class with bitmaps and enjoy the new quality. This nice control just had to be shared
    1.1 April 2001 Use Caption as default text. Changed from STL to Afx templates. After a suggestion I changed SetBackColor to SetBkColor. I apologize for keeping this baby for myself because I wanted to add and change more
    1.2 May 2002 Added option to draw immediately. Changed CDigiString to CDigiStatic because it is a derived from a Static control. After giving no problems for long time it was ready to be released again
    1.3 October 2002 Added transparency option with help of Daniel. Introduction of 5 new characters /\[]' (suggested by daniel for using in his great Winamp plugin). Added new DS_NO_OFF and DS_SOFT styles to respectively not to show segments that are "off" and to remove the soft edge of a segment. Improved demo app with skin was created to show all the options. This will be the third release and I call it the "feature update"
    You must Sign In to use this message board.
     
     
    Per page   
     FirstPrevNext
    GeneralGreat but out of date
    tlhintoq
    9:37 15 Sep '09  
    This appears to be a great control and I see there has been no activity here for 3 years.

    Any chance of this getting updated? Would be nice if it didn't rely on MFC for example. Would also make a wonderful UserControl that can be added to Visual Studio Toolbox and just dropped on a form.

    Line 283 of "dib256.cpp"
    pFile->WriteHuge(m_pPixels,
    DWORD((dwPadWidth*(DWORD)m_pInfo->bmiHeader.biBitCount*GetHeight())/8) );
    throws an error: "error C2039: 'WriteHuge': is not a member of CFile
    Suprisingly commenting out that line doesn't seem to alter the demo application, but I doubt it was there for decoration so it must serve a purpose under some condition.
    GeneralRe: Great but out of date
    Apuhjee
    8:17 22 Oct '09  
    I think you were looking for the Visual Basic section. Good luck!
    GeneralMemory leak
    Max2351
    1:00 1 Mar '06  
    For compile in Visual Studio 2005:
    Add "int iChar" in for loop in file Digistatic.cpp(1035)

    Have got a memory leak, show by MFC memory leak tracking in function :
    CDSegment CDSegment::operator=(const CDSegment &Segment)
    at pNewPoints = new CPoint[m_nCount]; and pNewTypes = new BYTE[m_nCount];

    No one have the same pb ?

    thank
    GeneralRe: Memory leak
    Michel Wassink
    3:40 1 Mar '06  
    Max2351 wrote:
    For compile in Visual Studio 2005:
    Add "int iChar" in for loop in file Digistatic.cpp(1035)

    I do not have VS2005 yet, but I have read somewhere that new compiler checks better when variables go out of scoop. I did not know I am also that sloppy..cool! Cool

    Max2351 wrote:
    Have got a memory leak, show by MFC memory leak tracking in function :
    CDSegment CDSegment::operator=(const CDSegment &Segment)

    CDSegment CDSegment::operator=(const CDSegment &Segment) makes a deep copy together with the copy contructor. The function CDSegment::FreeSegment() deletes the old buffers. So basically there is no memory leak Dead . Look for "deep copy" in a C++ textbook for more information

    Enjoy the controlSmile

    Michel Wassink

    We must make user friendly software. Where are friendly users?
    QuestionRe: Memory leak
    Willi_83
    13:01 7 Jul '09  
    Hello,

    I have also a problem with a memory leak using this control.

    It seems that the memory is lost every time the control is redrawn.


    When you move the window of my application some memory is lost. Also if you change the text of the control!


    I have the same problem with the CLcd7 Class.

    Can anyone help me please? Confused

    Thanks
    AnswerRe: Memory leak
    Michel Wassink
    11:26 9 Jul '09  
    Hello Willi_83,

    Can you describe how you create the control? Please try the demo apllication to see if it shows the same problem. How do you detect the memory loss?
    You can also send me some code which gives the problem.

    I hope I can help you with your problem.

    regards,

    Michel Wassink

    We must make user friendly software. Where are friendly users?

    GeneralRe: Memory leak
    Willi_83
    10:23 26 Jul '09  
    Hello,

    I'm very sorry! The memory leak I had in my application was NOT from the grandiose Digistatic class. Blush


    Excuse me!!!
    GeneralModify for displaying comma
    Samuele
    0:00 1 Feb '06  
    Here a little modify to display also comma character...
    This can be useful if you have to display numbers in some countries those require ',' instead of '.' (i.e. in Germany Cool ).
    Samuele Wink


    #define MAXSEGCHAR7 12 // Number of supported 7 segment characters
    #define MAXSEGCHAR14 45 // Number of supported 14 segment characters
    #define MAXSEGSEMCOL 2 // Number of supported 3 segment characters
    #define MAXSEGCOMMA 1 // Added #define NORM_DIGIHEIGHT 83 // All characters must have this height
    [...]

    BYTE CHAR_COMMA[MAXSEGCOMMA] = {0x01};

    #define X1 4 #define X2 13
    #define X1W 19 #define X2W 32
    #define Y1 68 #define Y2 77
    #ifdef _WIDE_COMMA
    // for wide comma character space
    CPoint PtSegCm[3] = {CPoint( X1W+3,Y1), CPoint( X1W,Y2), CPoint(X2W,Y1)};
    #else // small comma character space
    CPoint PtSegCm[3] = {CPoint( X1+2,Y1), CPoint( X1,Y2), CPoint(X2,Y1)};

    #endif BYTE TpSegCm[3] = {PT_MOVETO, PT_LINETO, PT_LINETO};

    [...]

    class CDigiCommaChar : public CDigiChar
    {
    public:
    CDigiCommaChar();
    void SetElementData(WORD wSegmData, int iDispStyle);
    };

    [...]


    ////////////////////////////////////////////////////////////////////////////
    // CDigiCommaCombi
    CDigiCommaChar::CDigiCommaChar()
    {
    #ifdef _WIDE_SEMICOLON
    m_Width = 49;
    #else m_Width = 18;
    #endif m_NSegments = 1;
    }

    void CDigiCommaChar::SetElementData(WORD wSegmData, int iDispStyle)
    {
    CDSegment DSegment;
    LPPOINT lpSegPoints = NULL;
    LPBYTE lpType = NULL;
    int nCount = 0;

    m_SegmentArray.RemoveAll();

    lpSegPoints = PtSegCm;
    lpType = TpSegCm;
    nCount = 3;

    // Copy data to segment array...
    DSegment.DefPoints(lpSegPoints, lpType, nCount);
    m_SegmentArray.Add(DSegment);

    CDigiChar::SetElementData(wSegmData, iDispStyle);
    }

    [...]


    CDigiChar * CDigiStatic::DefineChar(TCHAR cChar)
    {

    [...]

    // Spcial characters...
    iIndex = 0;
    switch(cChar)
    {
    case _T(':'): iIndex++;
    case _T('.'): pDChar = new CDigiColonDotChar;
    pDChar->SetElementData(CHAR_SEMCOL[iIndex], m_DispStyle);
    break;
    case _T(','): pDChar = new CDigiCommaChar;
    pDChar->SetElementData(CHAR_COMMA[iIndex], m_DispStyle);
    break;
    [...]

    GeneralUsing in a CFormView
    sbt1
    8:40 8 Oct '05  
    I'm having problems using this in a formview.

    I followed in instructions on adding it, and inserted the code in the view class's OnInitialUpdate:

    void CAssignmentView::OnInitialUpdate()
    {
    CFormView::OnInitialUpdate();
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();

    m_LedText.SetBkColor(WHITE);
    m_LedText.SetColor(WHITE,LIGHTBLUE);
    m_LedText.ModifyDigiStyle(CDigiStatic::DS_NO_OFF,CDigiStatic::DS_SOFT);

    m_LedText.SetText("51008");
    m_LedText.ShowWindow(TRUE);

    }

    but I get debug asserts:

    _AFXWIN_INLINE void CWnd::Invalidate(BOOL bErase)
    { ASSERT(::IsWindow(m_hWnd)); ::InvalidateRect(m_hWnd, NULL, bErase); }

    I also tried moving the code to the ShowWindow() function, same results.

    If I run in Release mode, no errors but the display doesn't show up.
    GeneralSolution- for anyone else trying to do this
    sbt1
    13:51 8 Oct '05  
    You need to edit the DDX line and change it from DDX_Text to DDX_Control:

    void CAssignmentView::DoDataExchange(CDataExchange* pDX)
    {
    CFormView::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAssignmentView)
    DDX_Control(pDX, IDC_LEDTEXT, m_LedText);
    //}}AFX_DATA_MAP
    }

    GeneralCompiling errors
    kezhu
    18:33 1 Sep '05  
    Hi:

    I've got the following compiling errors:

    Compiling...
    Digistatic.cpp
    D:\CodeProj Test\Static Cotrol\Digistatic\Digistatic.cpp(1031) : error C2664: 'AfxTrace' : cannot convert parameter 1 from 'char [7]' to 'const unsigned short *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    HMXCheckBox.cpp
    D:\CodeProj Test\Static Cotrol\Digistatic\HMXCheckBox.cpp(191) : error C2664: 'strcpy' : cannot convert parameter 1 from 'unsigned short [32]' to 'char *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    D:\CodeProj Test\Static Cotrol\Digistatic\HMXCheckBox.cpp(379) : error C2664: 'strcpy' : cannot convert parameter 1 from 'unsigned short [32]' to 'char *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    HMXStatic.cpp
    D:\CodeProj Test\Static Cotrol\Digistatic\HMXStatic.cpp(190) : error C2664: 'strcpy' : cannot convert parameter 1 from 'unsigned short [32]' to 'char *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    D:\CodeProj Test\Static Cotrol\Digistatic\HMXStatic.cpp(351) : error C2664: 'strcpy' : cannot convert parameter 1 from 'unsigned short [32]' to 'char *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Generating Code...
    Error executing cl.exe.

    counter.exe - 5 error(s), 0 warning(s)

    Can anyone help me to sort out the problems?

    Thanks.

    Ke
    GeneralRe: Compiling errors
    Rick York
    19:54 1 Sep '05  
    Looks to me like something is expecting Unicode and something else isn't giving it.

    I think the compile options were set for Unicode but the code is not capable of it. Check out the TCHAR type and related functions.

    GeneralRe: Compiling errors
    Michel Wassink
    20:54 1 Sep '05  
    Thank you for pointing this out. The code seems to be not fully unicode compliant.
    To resolve this, change all literal strings from "" to _T("") and strcpy() to _tcscpy() Then everything will compile just fine.

    regards,

    Michel Wassink

    We must make user friendly software. Where are friendly users?
    GeneralFANTASTIC code !!!
    KurtCocain
    10:47 17 Aug '04  
    Thank you for the great code. I needed something like that into my app. THANKS for the directions on how to implement!!! thats very important!
    GeneralRe: FANTASTIC code !!!
    Michel Wassink
    20:45 5 Oct '04  
    Thank you for your commentSmile

    Michel Wassink

    We must make user friendly software. Where are friendly users?
    GeneralCompilation Errors
    rmnowick
    16:22 9 Mar '04  
    Hello,
    I added the 6 files in question into my foldar that contains the source code for my current project. In Visual Studio I then went into the file menu and selected "Add existing item" for each of the 6 files in question. I then tried to build my code as it currently existed, just to verify that adding the new routines would not cause a problem. I then received 102 compilation errors and 3 warnings.

    I'll include the entire list in case anyone is out there that has worked through this before.

    Digistatic.cpp
    WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(80) : error C2061: syntax error : identifier 'CDC' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(103) : error C2061: syntax error : identifier 'CDC' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(127) : error C2504: 'CStatic' : base class undefined
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(180) : error C2144: syntax error : 'void' should be preceded by ';' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(180) : error C2501: 'CDigiStatic::afx_msg' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(181) : error C2146: syntax error : missing ';' before identifier 'BOOL' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(181) : error C2501: 'CDigiStatic::afx_msg' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(181) : error C2061: syntax error : identifier 'CDC' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(186) : warning C4518: 'void ' : storage-class or type specifier(s) unexpected here; ignored
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(186) : error C2146: syntax error : missing ';' before identifier 'DoInvalidate' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(186) : warning C4183: 'DECLARE_MESSAGE_MAP': missing return type; assumed to be a member function returning 'int' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.h(186) : warning C4183: 'DoInvalidate': missing return type; assumed to be a member function returning 'int' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(26) : error C2504: 'CDC' : base class undefined
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(28) : error C2146: syntax error : missing ';' before identifier 'm_bitmap' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(28) : error C2501: 'CMemDC::CBitmap' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(28) : error C2501: 'CMemDC::m_bitmap' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(29) : error C2143: syntax error : missing ';' before '*' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(29) : error C2501: 'CMemDC::CBitmap' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(29) : error C2501: 'CMemDC::m_oldBitmap' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(30) : error C2143: syntax error : missing ';' before '*' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(30) : error C2501: 'CMemDC::CDC' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(30) : error C2501: 'CMemDC::m_pDC' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2143: syntax error : missing ')' before '*' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2143: syntax error : missing ';' before '*' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2460: 'CMemDC::CDC' : uses 'CMemDC', which is being defined
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(26) : see declaration of 'CMemDC' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2501: 'CMemDC::pDC' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2143: syntax error : missing ';' before '*' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2501: 'CMemDC::CRect' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2864: 'pRect' : only const static integral data members can be initialized inside a class or struct c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2501: 'CMemDC::pRect' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2146: syntax error : missing ';' before identifier 'transparent' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2501: 'CMemDC::BOOL' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2059: syntax error : ')' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2864: 'transparent' : only const static integral data members can be initialized inside a class or struct c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2501: 'CMemDC::transparent' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2143: syntax error : missing ';' before ':' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C2327: 'CMemDC::CDC' : is not a type name, static, or enumerator
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(35) : error C3861: 'CDC': identifier not found, even with argument-dependent lookup
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(36) : error C2501: 'CMemDC::operator`.alignment member.'' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(37) : error C2143: syntax error : missing '
    )' before '!=' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(37) : error C2059: syntax error : ')' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(37) : error C2238: unexpected token(s) preceding ';' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(40) : error C2065: 'pDC' : undeclared identifier
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(40) : error C2864: '
    m_pDC' : only const static integral data members can be initialized inside a class or struct
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(40) : error C2501: '
    CMemDC::m_pDC' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(41) : error C2864: '
    m_oldBitmap' : only const static integral data members can be initialized inside a class or struct
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(41) : error C2501: '
    CMemDC::m_oldBitmap' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(42) : error C2227: left of '
    ->IsPrinting' must point to class/struct/union
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(42) : error C3861: 'pDC': identifier not found, even with argument-dependent lookup
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(42) : error C2864: '
    m_bMemDC' : only const static integral data members can be initialized inside a class or struct
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(42) : error C2501: '
    CMemDC::m_bMemDC' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(45) : error C2059: syntax error : '
    if' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(45) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(47) : error C2059: syntax error : '
    else' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(47) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(51) : error C2059: syntax error : '
    if' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(51) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(62) : error C2059: syntax error : '
    else' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(62) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(70) : error C2059: syntax error : '
    if' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(71) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(76) : error C2059: syntax error : '
    else' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(77) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(84) : error C2588: '
    ::~CMemDC' : illegal global destructor
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(86) : error C2065: '
    m_bMemDC' : undeclared identifier
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C2065: '
    m_pDC' : undeclared identifier
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C2227: left of '
    ->BitBlt' must point to class/struct/union
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C2065: 'm_rect' : undeclared identifier
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C2228: left of '
    .left' must have class/struct/union type
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C2228: left of '.top' must have class/struct/union type
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C2228: left of '.Width' must have class/struct/union type
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C2228: left of '.Height' must have class/struct/union type
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(89) : error C2673: 'CMemDC' : global functions do not have 'this' pointers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(89) : error C2228: left of '
    .left' must have class/struct/union type
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(89) : error C2228: left of '.top' must have class/struct/union type
    type is '
    'unknown-type'' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C3861: 'm_rect': identifier not found, even with argument-dependent lookup
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C3861: '
    m_rect': identifier not found, even with argument-dependent lookup
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(88) : error C3861: '
    m_rect': identifier not found, even with argument-dependent lookup
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(89) : error C3861: '
    m_rect': identifier not found, even with argument-dependent lookup
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(89) : error C3861: '
    m_rect': identifier not found, even with argument-dependent lookup
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(92) : error C2065: '
    m_oldBitmap' : undeclared identifier
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(97) : error C2065: '
    m_hDC' : undeclared identifier
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(97) : error C2065: '
    m_hAttribDC' : undeclared identifier
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(102) : error C2143: syntax error : missing '
    ;' before '*' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(102) : error C2501: 'CMemDC' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(102) : error C2373: '
    CMemDC' : redefinition; different type modifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(84) : see declaration of '
    CMemDC' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(103) : error C2501: 'operator`->'' : missing storage-class or type specifiers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(103) : error C2801: 'operator ->' must be a non-static member
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(104) : error C2673: 'operator`->'' : global functions do not have 'this' pointers
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(108) : error C2833: '
    operator CMemDC' is not a recognized operator or type
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(108) : error C2059: syntax error : '
    newline' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(109) : error C2143: syntax error : missing ';' before '{' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(109) : error C2447: '{' : missing function header (old-style formal list?)
    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(112) : error C2059: syntax error : '
    }' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(112) : error C2143: syntax error : missing ';' before '}' c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(112) : error C2059: syntax error : '}' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2587: 'P' : illegal use of local variable as default parameter
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(166) : see declaration of '
    P' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2228: left of '.x' must have class/struct/union type
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2587: '
    M' : illegal use of local variable as default parameter
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(166) : see declaration of '
    M' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2228: left of '.x' must have class/struct/union type
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2587: '
    P' : illegal use of local variable as default parameter
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(166) : see declaration of '
    P' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2228: left of '.x' must have class/struct/union type
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2587: '
    P' : illegal use of local variable as default parameter
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(166) : see declaration of '
    P' c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : error C2228: left of '.y' must have class/struct/union type
    c:\VSAVANT4\EXAMPLES\SDKDEMO\Digistatic.cpp(168) : fatal error C1003: error count exceeds 100; stopping compilation

    It looks as if maybe they all cascaded because the CDC base class was detected as being not defined:

    c:\VSAVANT4\EXAMPLES\SDKDEMO\MemDC.h(26) : error C2504: 'CDC' : base class undefined

    Maybe there is an additional .h file that I need to include in MemDC.h? Any help would be appreciated.

    Robert
    GeneralRe: Compilation Errors
    rmnowick
    16:37 9 Mar '04  
    I needed to include afxwin.h in both MemDC.h and DigiStatic.h. This eliminated the compilation errors but I am now getting linker errors:

    Compiling...
    Digistatic.cpp
    WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)
    Linking...
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCD.lib(dbgdel.obj)
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in LIBCD.lib(new2.obj)
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCD.lib(delete2.obj)
    LINK : warning LNK4098: defaultlib 'LIBC' conflicts with use of other libs; use /NODEFAULTLIB:library
    nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
    nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
    Debug/SDKDEMO.exe : fatal error LNK1120: 2 unresolved externals

    Build log was saved at "file://c:\Vsavant4\Examples\Sdkdemo\Debug\BuildLog.htm" SDKDEMO - 7 error(s), 1 warning(s)

    GeneralRe: Compilation Errors
    Michel Wassink
    20:45 9 Mar '04  
    Hello Robert,

    When building digistatic.cpp, the first file it includes is stdafx.h.
    Normally with appwizard generated apps Microsoft will include which defines the CDC object and will not give you compilation errors.

    Try to compile the Demo application too and check if you get the same errors.

    regards,

    Michel Wassink

    We must make user friendly software. Where are friendly users?
    GeneralRe: Compilation Errors
    rmnowick
    6:33 10 Mar '04  
    Michel,
    Thanks for getting back to me. I checked in digistatic.cpp and the include for stdafx.h is there. I used your 6 files "exactly" as they were:

    Add digistatic.h, digistatic.cpp, memdc.h, curvefit.h, curvefit.cpp and rgbcolor.h to your project environment

    The only changes that I have made since then was to add afxwin.h in both MemDC.h and DigiStatic. This got rid of the compilation errors but then resulted in the linker errors that I am now getting.

    I went back to the original counter project that you supplied. I am able to both build and run your project without having to include afxwin.h in the files that I mentioned above. I guess I need to look through the linker properties to verify that all the settings are the same?

    I just want to have numerous displayed values, exactly like the 56.873 that you have in the upper right corner. These will be showing voltage and temperature levels for our experiment. I looked through the code and it seems like it should be very easy to do once I figure out the linker errors.

    Thanks,
    Robert
    GeneralRe: Compilation Errors
    rmnowick
    14:47 10 Mar '04  
    Here are views of all the linker options from my project versus the counter project. I seem to have many more.

    My linker command line options:
    /OUT:"Debug/SDKDEMO.exe" /INCREMENTAL:NO /NOLOGO /DEBUG /PDB:"Debug/SDKDEMO.pdb" /SUBSYSTEM:WINDOWS /MACHINE:X86 winmm.lib comctl32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "\Documents and Settings\Jpl\My Documents\mars\CPP Projects\Serial\_output\debug\SerialD.lib"

    The counter project linker command line options:
    /OUT:".\Debug/counter.exe" /INCREMENTAL:NO /NOLOGO /DEBUG /PDB:".\Debug/counter.pdb" /SUBSYSTEM:WINDOWS /MACHINE:X86

    Could the errors be the result of some kind of conflict or duplication with all the libraries that I seem to be including? This is my first Visual C++ project so I'm pretty unfamiliar with this and I could very well be off on the wrong track.

    Robert
    GeneralRe: Compilation Errors
    ananth_rs
    22:36 5 May '06  
    Posting for the sake of posterity :

    You could probably resolve __beginthreadex and __endthreadex linker errors by changing your build settings to "Use MFC in a Shared DLL"
    GeneralWTL Version?
    mjsiers
    12:06 19 Nov '03  
    Has anyone ported this control to work with WTL?
    GeneralWonderful Piece of Code
    Karen0302
    7:40 7 Nov '03  
    This is one of the best pieces of code I have used. Small, easy to use and extremely functional. All in all a superb piece of work!!!
    GeneralRe: Wonderful Piece of Code
    Michel Wassink
    20:59 9 Nov '03  
    Thank you Karen for your comment Rose

    Michel Wassink

    We must make user friendly software. Where are friendly users?
    GeneralSmall
    Bamaco
    10:40 24 Mar '03  
    Does not look very good when small.Frown

    This is the only complain that I could give.

    Also, I have attempted to these 14 segment characters:

    0x2006 // "arrow up"
    0x0418 // "arrow down"

    and it really does not look like I would expect it to.

    Perhaps it's too close to a "real" led as iterpreted
    by a programmer ?





    Last Updated 6 Oct 2002 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010