Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
This class allows the developer to quickly place a countdown control in a user interface. It is publicly derived from the CGCColorStatic class to provide the ability to control the background and text colors, the font utilized, the border style and more.
The CGCCountdownCtrl class provides the method Set() to set the starting point for the countdown control.
BOOL Set(const UINT Days = 0, const UINT Hours = 1, const UINT Minutes = 0, const UINT Seconds = 0, const BOOL TerminateAtZero = TRUE, const UINT Style = CD_DAYS, void (*fn_pointer)(UINT CtrlID) = NULL);The Set() method accepts the following parameters:
The parameter Style, is used to control the way that the countdown control is presented. The styles that may be specified are as follows:
CD_DAYS - Display days, hours, minutes and seconds as DD:HH:MM:SS
CD_HOURS - Display hours, minutes and seconds as HH:MM:SS
CD_MINUTES - Display minutes and seconds as MM:SS
CD_SECONDS - Display seconds only as SS.
The final parameter to Set(), allows the client to specify a procedure (return type void) to be called when zero is reached in the countdown. The procedure should accept a single parameter of type UINT that will be passed the control's id.
If the client wishes to perform a 2 day, 12 hour and 30 minute countdown, and to stop when 0 is reached, a call similar to the following would be made:
By design, the CGCCountdownCtrl class only allows negative countdown when the specified style is CD_DAYS to allow, essentially, an infinite negative countdown. However, if this is desired, ensure that the control is wide enough to display a large number of days.
When specifying any other styles, the CGCCountdownCtrl class is designed to terminate at zero. That is, specifying the CD_HOURS, CD_MINUTES or CD_SECONDS style implies TRUE for the TerminateAtZero parameter.
To start the countdown, the client should call the method
BOOL Start();To stop the countdown, the client should call the method
void Stop();When calling Stop(), the countdown is halted at the point in the countdown at which Stop() was called. The countdown may be resumed at the point at which is was stopped by calling Start() again.
The CGCCountdownCtrl class provides the method
BOOL EndCountAtZero(const BOOL bZero = TRUE);to allow the client to change the setting of the TerminateAtZero parameter specified when Set() was called at any time during execution of the countdown or while the countdown is stopped.
The CGCCountdownCtrl class overrides the OnTimer() handler to update the control's display. Its timer uses a private ID of CNTDWN_UPDATE_TIMER_ID. This ID is defined as WM_APP+2 because the CGCColorStatic class utilizes a timer ID of WM_APP+1. By having a separate ID for the control's display update timer, the client is able to combine flashing with the update of the countdown display. If a new class is derived from the CGCCountdownCtrl class that must also override the OnTimer() handler, the developer should define that class' timer id to be WM_APP+3 or greater. The class's OnTimer() handler should also call the CGCCountdownCtrl class' OnTimer() if needed.
HOW TO USE CGCCountdownCtrl
DownloadsDownload demo application - 100 Kb
Download demo source - 38 Kb