Click here to Skip to main content
13,048,406 members (147,522 online)
Click here to Skip to main content
Add your own
alternative version


60 bookmarked
Posted 16 Jan 2000

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

    You may also be interested in...


    Comments and Discussions

    Generallicense of CStaticTime Pin
    Jan777777710-May-10 5:46
    memberJan777777710-May-10 5:46 
    Generalgood,essy to use,but... Pin
    dicker19-Jun-02 16:59
    memberdicker19-Jun-02 16:59 
    GeneralRight Align Text Pin
    Anonymous21-Feb-02 10:46
    memberAnonymous21-Feb-02 10:46 
    GeneralRe: Right Align Text Pin
    robot_chou21-Jul-09 21:18
    memberrobot_chou21-Jul-09 21:18 
    GeneralWhen this program is running, my mouse glitters Pin
    Ray Yang22-Feb-01 15:03
    memberRay Yang22-Feb-01 15:03 
    QuestionDoes not work on a dialog Bar? Pin
    Prasad17-Aug-00 5:53
    sussPrasad17-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.

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