Click here to Skip to main content
Click here to Skip to main content
Go to top

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

Introduction

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

Comments

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.

License

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

Share

About the Author

Sunil.S.

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.

Comments and Discussions

 
Questionbug [modified] PinmemberJacky Chong14-Jun-06 21:59 
GeneralWaiting for reply,thanks Pinmembereexiao4-May-04 5:48 
Hello,my name is Jenny.
I got a problem when I added your clock to my project. The clock worked correctly but it caused the unsoundly exiting of my project, when I pressed any button in my dialog.
If you have met the same problem or have the solution ,please email me.
I hope for your reply.
Thanks very much.Smile | :)
 
Shawn Jenny
Generalproblem Pinmembersofiane6128-Mar-04 23:17 
GeneralProblem Pinmembermodeonetwo27-Feb-04 7:05 
GeneralRe: Problem PinmemberSunil.S.2-Mar-04 17:51 
GeneralMonth & year buttons disappear. PinmemberWREY13-Feb-04 23:03 
GeneralRe: Month & year buttons disappear. PinmemberSunil.S.15-Feb-04 17:05 
QuestionIs this your own Clock? PinsussAnonymous13-Feb-04 7:58 
AnswerRe: Is this your own Clock? PinmemberJohn M. Drescher13-Feb-04 18:54 
AnswerRe: Is this your own Clock? PinmemberSunil.S.15-Feb-04 16:42 

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 | Mobile
Web04 | 2.8.140916.1 | Last Updated 13 Feb 2004
Article Copyright 2004 by Sunil.S.
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid