Click here to Skip to main content
Click here to Skip to main content

An LED time and value display control

, 16 Jan 2000
Rate this:
Please Sign up or sign in to vote.
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

    <!-- Article Starts -->

    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.


    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") 


    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


    About the Author

    Jason Troitsky

    United Kingdom United Kingdom
    No Biography provided

    Comments and Discussions

    Generallicense of CStaticTime PinmemberJan777777710-May-10 6:46 
    Generalgood,essy to use,but... Pinmemberdicker19-Jun-02 17:59 
    GeneralRight Align Text PinmemberAnonymous21-Feb-02 11:46 
    GeneralRe: Right Align Text Pinmemberrobot_chou21-Jul-09 22:18 
    GeneralWhen this program is running, my mouse glitters PinmemberRay Yang22-Feb-01 16:03 
    QuestionDoes not work on a dialog Bar? PinsussPrasad17-Aug-00 6:53 

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

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

    | Advertise | Privacy | Terms of Use | Mobile
    Web03 | 2.8.1411022.1 | Last Updated 17 Jan 2000
    Article Copyright 2000 by Jason Troitsky
    Everything else Copyright © CodeProject, 1999-2014
    Layout: fixed | fluid