Click here to Skip to main content
13,764,268 members
Click here to Skip to main content
Add your own
alternative version


44 bookmarked
Posted 12 Feb 2004

Wall Clock Control

, 12 Feb 2004
Rate this:
Please Sign up or sign in to vote.
This article explains how to add a wall clock control to a dialog-based application.

Sample Image - wallclockctrl.jpg


This article explains how to add a wall clock control to your dialog-based application. This wall clock control is derived from CStatic. You can customize the clock as per your requirements, viz, change clock hand color, clock dial color, tick color or text color. You can even change your system date/time settings using this control. All you have to do is to change the date/time settings of the clock and system date/time settings will change automatically.

Using the code

Steps for adding the wall clock control to your application:

  1. Copy files WallClockST.h and WallClockST.cpp to your project directory and add them to your project.
  2. Place a Static Control to your dialog from the Control ToolBox.
  3. Using ClassWizard, add a member variable m_Clock for the Static Control, to your dialog class. Make sure that it is a control variable.

  4. Now, in your dialog class header file, add this line on top of your class definition:
    #include "WallClockST.h"
  5. Replace the following line in your dialog class header file:
    CStatic m_Clock;

    with this piece of code:

    CWallClockST m_Clock;

That's it!, Your Wall Clock application is ready. Just execute your program to see the clock running.

Member Functions

Following are the member functions which can be used to change the clock settings:

 void LoadColorSettings();
 // Load the color settings of the clock from your PC.

void SaveColorSettings();
// Save the color settings to your PC.
// The clock settings will be saved as a .sys file in your system directory.

void StopClock();
// Stops the clock.

void StartClock();
// Restarts the clock.

void ResetDate();
// Reset the default date/time settings

void SetDateTime(COleDateTime dt);
// Sets new date/time settings for the clock

void SetTextColor(COLORREF color);
// Sets the text color of the clock

COLORREF GetTextColor();
// Retreives the current text color of the clock

COLORREF GetTickColor();
// Retreives the current tick color of the clock

void SetTickColor(COLORREF color);
// Sets the tick color of the clock
void SetDialColor(COLORREF color);
// Sets the dial color of the clock

COLORREF GetDialColor();
// Retreives the current dial color of the clock

COLORREF GetHandColor();
// Retreives the current hand color of the clock

void SetHandColor(COLORREF color);
// Sets the hand color of the clock


I got the inspiration to develop this control after reading the article by A.Riazi on Analog Clock. I have drawn a circular dial and provided tick marks for the clock, so as to give it the look and feel of a wall clock. Riazi's clock does not provide the facility to change the dial color, tick color and text color of the clock. Also, this control has an advantage in that it displays the current date, which is not present in Riazi's clock.


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

India India
I am currently working as Senior Software Engineer in a U.S.based Multi National Company. I have worked on projects related to various fields including Process Control, Security Solutions usng Biometrics, Artificial Intelligence etc.

I have developed many programs related to security solutions and embedded systems.

You may also be interested in...


Comments and Discussions

Questionbug [modified] Pin
Jacky Chong14-Jun-06 22:59
memberJacky Chong14-Jun-06 22:59 
GeneralWaiting for reply,thanks Pin
eexiao4-May-04 6:48
membereexiao4-May-04 6:48 
Generalproblem Pin
sofiane6129-Mar-04 0:17
membersofiane6129-Mar-04 0:17 
GeneralProblem Pin
modeonetwo27-Feb-04 8:05
membermodeonetwo27-Feb-04 8:05 
GeneralRe: Problem Pin
Sunil.S.2-Mar-04 18:51
memberSunil.S.2-Mar-04 18:51 
May be this is due to improper placement of the controls in your dialog. Try adjusting the controls.
GeneralMonth & year buttons disappear. Pin
WREY14-Feb-04 0:03
memberWREY14-Feb-04 0:03 
GeneralRe: Month & year buttons disappear. Pin
Sunil.S.15-Feb-04 18:05
memberSunil.S.15-Feb-04 18:05 
QuestionIs this your own Clock? Pin
Anonymous13-Feb-04 8:58
memberAnonymous13-Feb-04 8:58 
AnswerRe: Is this your own Clock? Pin
John M. Drescher13-Feb-04 19:54
memberJohn M. Drescher13-Feb-04 19:54 
AnswerRe: Is this your own Clock? Pin
Sunil.S.15-Feb-04 17:42
memberSunil.S.15-Feb-04 17:42 

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 | Cookies | Terms of Use | Mobile
Web05-2016 | 2.8.181113.4 | Last Updated 13 Feb 2004
Article Copyright 2004 by Sunil.S.
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid