Click here to Skip to main content
15,867,867 members
Articles / Desktop Programming / MFC
Article

An LED time and value display control

Rate me:
Please Sign up or sign in to vote.
4.74/5 (10 votes)
16 Jan 2000 105.9K   5.1K   67   6
A control to display times and numbers using an LED digital-style display
  • Download demo project - 47 Kb
  • Download source files - 4 Kb
  • Sample Image - CStaticTime.gif

    The CStaticTime class simplifies the display of time and numerical values using a digital-style counter - without using bitmaps.

    The class uses Keith Rule's double-buffering class to completely remove flicker, and it uses MoveTo/LineTo for drawing, and therefore has no dependancies on bitmaps.

    The class also uses static control's dimensions to calculate metrics, which means it'll draw well formed digits with minimal intervention, regardless of the control's size.

    Methods

    void Display(CString strDisplay) 

    This function will display your string in a digital counter style, ignoring all characters except: 0 1 2 3 4 5 6 7 8 9 . :

    void Display(UINT uSecs=0, UINT uMins=0, UINT uHours=0, UINT uDays=0, CString strFormat="%D:%H:%M:%S") 

    This function enables you to simply tell the control to display, for instance, 5196 seconds by simply typing Display(5196). The output will be displayed in D:H:M:S format unless you change the format string (last parameter) accordingly

    void SetColourFaded( COLORREF cr ) 

    Use this to manually override the colour used for the faded notches drawn in the control. If you don't override the faded colour and the m_bDrawFaded is "true", then the control will draw a colour that is "one third" the colour of the specified foreground (m_crForeground)

    void SetColourBackground(COLORREF crColour) 
    Calling this with no parameters will cause the control to set the background colour to ::GetSysColor(COLOR_BTNFACE)
    void SetColourForeground(COLORREF crColour) 
    Calling this with no parameters will cause the control to set the foreground colour to ::GetSysColor(COLOR_BTNTEXT)
    void DisplayCurrentTime(CString strFormat = "%H:%M:%S") 
    Guess!!

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    United Kingdom United Kingdom
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    Generallicense of CStaticTime Pin
    Jan777777710-May-10 5:46
    Jan777777710-May-10 5:46 
    Generalgood,essy to use,but... Pin
    dicker19-Jun-02 16:59
    dicker19-Jun-02 16:59 
    GeneralRight Align Text Pin
    21-Feb-02 10:46
    suss21-Feb-02 10:46 
    GeneralRe: Right Align Text Pin
    leochou072921-Jul-09 21:18
    leochou072921-Jul-09 21:18 
    GeneralWhen this program is running, my mouse glitters Pin
    Ray Yang22-Feb-01 15:03
    Ray Yang22-Feb-01 15:03 
    QuestionDoes not work on a dialog Bar? Pin
    Prasad17-Aug-00 5:53
    Prasad17-Aug-00 5:53 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.