Download demo project - 47 Kb
Download source files - 4 Kb
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!!