Click here to Skip to main content
11,632,104 members (71,799 online)
Click here to Skip to main content

CClockST v1.3

, 12 Jul 2002 163.4K 6.6K 80
Rate this:
Please Sign up or sign in to vote.
A simple digital clock and date class derived from the MFC CStatic class
<!-- Download Links --> <!-- Article image -->

Sample Image - CClockST.png

Abstract

CClockST is a class derived from MFC CStatic class. CClockST just subclasses the supplied CStatic control in your dialog and implements a simple clock and date!

Main CClockST features are:

  • An easy way to put a clock in you dialog/application
  • It's free!
  • Full source code included!
  • Cost-less implementation in existing applications

How to integrate CClockST in your application

In your project include the following files:

  • ClockST.h
  • ClockST.cpp
Also include the following bitmap resources:
  • IDB_CLOCKST_PANE (ClockST_pane.bmp)
  • IDB_CLOCKST_BIG (ClockST_big.bmp)
  • IDB_CLOCKST_SMALL (ClockST_small.bmp)
Use dialog editor to create a static text called, for example, IDC_CLOCKFRAME (no matter what size you give it, it will be resized by CClockST) and create a member variable for this static control:
CClockST m_Clock;
Now attach the static control to CClockST. For dialog-based applications, in your OnInitDialog:
// Call the base-class method
CDialog::OnInitDialog();

// Create the clock
m_Clock.SubclassDlgItem(IDC_CLOCKFRAME, this);
Or in your DoDataExchange:
// Call the base method
CDialog::DoDataExchange(pDX);

// Create the clock
DDX_Control(pDX, IDC_CLOCKFRAME , m_Clock);
Now start the clock, passing the ID resources of the bitmaps to use:
// Start clock
m_Clock.Start(IDB_CLOCKST_PANE, IDB_CLOCKST_BIG, IDB_CLOCKST_SMALL);
Your clock is now active! The static control created with dialog editor has been resized to
match the same size of the clock. There is no way to stop the clock once started.

Class methods

Start

Starts (and displays) the clock loading all the necessary bitmaps
and creating the worker thread.

// Parameters:
//     [IN]   nPaneID
//            ID number of the bitmap resource of the whole clock.
//     [IN]   nBigID
//            ID number of the bitmap resource of the big digits.
//     [IN]   nSmallID
//            ID number of the bitmap resource of the small digits.
//     [IN]   bAlternateDateFormat
//            TRUE to display date in mm-dd-yyyy format, else
//            FALSE to display date in dd-mm-yyyy format.
//
// Return value:
//     CLOCKST_OK
//        Function executed successfully.
//     CLOCKST_INVALIDRESOURCE
//        Some error loading bitmaps.
//     CLOCKST_THREADKO
//        Failed creating worker thread.
//
DWORD Start(int nPaneID, int nBigID, int nSmallID, BOOL bAlternateDateFormat = FALSE)
GetVersionI

Returns the class version as a short value.

// Return value:
//     Class version. Divide by 10 to get actual version.
//
static short GetVersionI()
GetVersionC

Returns the class version as a string value.

// Return value:
//     Pointer to a null-terminated string containig the class version.
//
static LPCTSTR GetVersionC()

History

  • v1.3 (10/July/2002)
    Fixed a problem in the OnPaint method
  • v1.2 (29/June/2002)
    Modified the Start method parameter list
  • v1.0 (15/June/1999)
    First release

Disclaimer

THE SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO REPONSIBILITIES FOR POSSIBLE DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE RISK OF USING THIS SOFTWARE.

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

Davide Calabro
Web Developer
Italy Italy
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 5 Pin
lion_1175-Sep-13 20:21
memberlion_1175-Sep-13 20:21 
GeneralMy vote of 5 Pin
huyl200212-Nov-12 1:50
memberhuyl200212-Nov-12 1:50 
Questionhelp Pin
tly88092216-Oct-12 8:29
membertly88092216-Oct-12 8:29 
AnswerRe: help Pin
huyl200212-Nov-12 2:34
memberhuyl200212-Nov-12 2:34 
QuestionAppreciate your wonderful job! Pin
returntorres17-Sep-11 5:16
memberreturntorres17-Sep-11 5:16 
GeneralThe modal Frame, border issues Pin
YDLU8-Sep-08 5:28
memberYDLU8-Sep-08 5:28 
Generalhelp Pin
junli15-Nov-07 22:40
memberjunli15-Nov-07 22:40 
GeneralRe: help Pin
GTiger17-Nov-07 4:35
memberGTiger17-Nov-07 4:35 
QuestionRe: help Pin
chen_zd2-Oct-08 15:37
memberchen_zd2-Oct-08 15:37 
Generalvery great !! Pin
ZhaoChunsheng25-May-07 22:28
memberZhaoChunsheng25-May-07 22:28 
Generalyou're great !! Pin
eyedeen23-Aug-05 13:52
membereyedeen23-Aug-05 13:52 
Generalbeginer Pin
dnqhung12-Jun-04 20:26
memberdnqhung12-Jun-04 20:26 
GeneralGreat Control! Pin
Christoph Lederer10-Feb-04 23:48
memberChristoph Lederer10-Feb-04 23:48 
Hi,

I really like your clock-control, looks very professional! And the button in your example project. Did you take it from another Code Project Thread or did you create it by yourself?

____________________________
Rule #1: code doesn't lie!
Rule #2: code never lies!
Rule #3: if the docs are incorrect -> take a look at the code!
GeneralRe: Great Control! Pin
Ravi Bhavnani10-Feb-04 23:56
memberRavi Bhavnani10-Feb-04 23:56 
GeneralRe: Great Control! Pin
Davide Calabro18-Aug-05 2:27
memberDavide Calabro18-Aug-05 2:27 
GeneralRe: Great Control! Pin
Ravi Bhavnani18-Aug-05 4:04
memberRavi Bhavnani18-Aug-05 4:04 
GeneralAssistance needed Pin
crystalyd18-Aug-03 23:18
membercrystalyd18-Aug-03 23:18 
GeneralRe: Assistance needed Pin
Davide Calabro18-Aug-03 23:29
memberDavide Calabro18-Aug-03 23:29 
GeneralRe: Assistance needed Pin
crystalyd19-Aug-03 21:49
membercrystalyd19-Aug-03 21:49 
GeneralRe: Assistance needed Pin
Davide Calabro19-Aug-03 23:52
memberDavide Calabro19-Aug-03 23:52 
GeneralRe: Assistance needed Pin
crystalyd20-Aug-03 16:09
membercrystalyd20-Aug-03 16:09 
GeneralRe: Assistance needed Pin
ccf25-May-04 3:36
memberccf25-May-04 3:36 
GeneralCStatic ?? help pls ! Pin
TontOnduWeb24-Jul-03 19:29
memberTontOnduWeb24-Jul-03 19:29 
GeneralRe: CStatic ?? help pls ! Pin
Davide Calabro24-Jul-03 20:58
memberDavide Calabro24-Jul-03 20:58 
GeneralRe: CStatic ?? help pls ! Pin
TontOnduWeb24-Jul-03 21:33
memberTontOnduWeb24-Jul-03 21:33 
GeneralStop Watch Option Wanted Pin
bachi22-Jun-03 19:55
memberbachi22-Jun-03 19:55 
GeneralRe: Stop Watch Option Wanted Pin
Davide Calabro24-Jul-03 20:59
memberDavide Calabro24-Jul-03 20:59 
GeneralRe: Stop Watch Option Wanted Pin
bachi25-Jul-03 3:36
memberbachi25-Jul-03 3:36 
GeneralRe: Stop Watch Option Wanted Pin
Davide Calabro25-Jul-03 4:15
memberDavide Calabro25-Jul-03 4:15 
Generalinvisible Pin
jiangyuyong21-May-03 22:16
memberjiangyuyong21-May-03 22:16 
Generalerror C2065: 'RT_GROUP_BITMAP' : undeclared identifier Pin
jiangyuyong22-Jan-03 14:12
memberjiangyuyong22-Jan-03 14:12 
Generalmistake Pin
jiangyuyong22-Jan-03 17:07
memberjiangyuyong22-Jan-03 17:07 
GeneralClock Size Pin
Anonymous15-Oct-02 19:34
sussAnonymous15-Oct-02 19:34 
GeneralRe: Clock Size Pin
Davide Calabro15-Oct-02 20:59
memberDavide Calabro15-Oct-02 20:59 
GeneralGREAT, but a little problem Pin
Martin Schneider9-Jul-02 4:30
memberMartin Schneider9-Jul-02 4:30 
GeneralRe: GREAT, but a little problem Pin
Davide Calabro9-Jul-02 6:21
memberDavide Calabro9-Jul-02 6:21 
GeneralHere is the fix Pin
Davide Calabro9-Jul-02 21:45
memberDavide Calabro9-Jul-02 21:45 
GeneralRe: Here is the fix Pin
Martin Schneider9-Jul-02 22:49
memberMartin Schneider9-Jul-02 22:49 
GeneralHELP!!!! Pin
Footan2-Jul-02 10:54
memberFootan2-Jul-02 10:54 
GeneralRe: HELP!!!! Pin
Davide Calabro2-Jul-02 21:35
memberDavide Calabro2-Jul-02 21:35 
GeneralRe: HELP!!!! Pin
Footan3-Jul-02 4:58
memberFootan3-Jul-02 4:58 
GeneralRe: HELP!!!! Pin
cshyung2-Jul-07 15:37
membercshyung2-Jul-07 15:37 
GeneralVery nice! Pin
Ravi Bhavnani2-Jul-02 3:42
memberRavi Bhavnani2-Jul-02 3:42 
GeneralWonderful !!! Pin
WREY1-Jul-02 23:54
memberWREY1-Jul-02 23:54 
GeneralRe: Wonderful !!! Pin
Davide Calabro2-Jul-02 1:35
memberDavide Calabro2-Jul-02 1:35 

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 | Terms of Use | Mobile
Web03 | 2.8.150728.1 | Last Updated 13 Jul 2002
Article Copyright 2002 by Davide Calabro
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid