Click here to Skip to main content
Licence 
First Posted 1 Jul 2002
Views 143,572
Bookmarked 69 times

CClockST v1.3

By | 12 Jul 2002 | Article
A simple digital clock and date class derived from the MFC CStatic class

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

About the Author

Davide Calabro

Web Developer

Italy Italy

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionAppreciate your wonderful job! Pinmemberreturntorres5:16 17 Sep '11  
GeneralThe modal Frame, border issues PinmemberYDLU5:28 8 Sep '08  
Generalhelp Pinmemberjunli22:40 15 Nov '07  
GeneralRe: help PinmemberGTiger4:35 17 Nov '07  
QuestionRe: help Pinmemberchen_zd15:37 2 Oct '08  
Generalvery great !! PinmemberZhaoChunsheng22:28 25 May '07  
Generalyou're great !! Pinmembereyedeen13:52 23 Aug '05  
hey there,
i just wanted to thank you for all the great code you've put out there. i've used your CButtonST and CBkDialogST before, and now i've come upon your CClockST.
great work !!
cheers
Generalbeginer Pinmemberdnqhung20:26 12 Jun '04  
GeneralGreat Control! PinmemberChristoph Lederer23:48 10 Feb '04  
GeneralRe: Great Control! PinmemberRavi Bhavnani23:56 10 Feb '04  
GeneralRe: Great Control! PinmemberDavide Calabro2:27 18 Aug '05  
GeneralRe: Great Control! PinmemberRavi Bhavnani4:04 18 Aug '05  
GeneralAssistance needed Pinmembercrystalyd23:18 18 Aug '03  
GeneralRe: Assistance needed PinmemberDavide Calabro23:29 18 Aug '03  
GeneralRe: Assistance needed Pinmembercrystalyd21:49 19 Aug '03  
GeneralRe: Assistance needed PinmemberDavide Calabro23:52 19 Aug '03  
GeneralRe: Assistance needed Pinmembercrystalyd16:09 20 Aug '03  
GeneralRe: Assistance needed Pinmemberccf3:36 25 May '04  
GeneralCStatic ?? help pls ! PinmemberTontOnduWeb19:29 24 Jul '03  
GeneralRe: CStatic ?? help pls ! PinmemberDavide Calabro20:58 24 Jul '03  
GeneralRe: CStatic ?? help pls ! PinmemberTontOnduWeb21:33 24 Jul '03  
GeneralStop Watch Option Wanted Pinmemberbachi19:55 22 Jun '03  
GeneralRe: Stop Watch Option Wanted PinmemberDavide Calabro20:59 24 Jul '03  
GeneralRe: Stop Watch Option Wanted Pinmemberbachi3:36 25 Jul '03  
GeneralRe: Stop Watch Option Wanted PinmemberDavide Calabro4:15 25 Jul '03  

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.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 13 Jul 2002
Article Copyright 2002 by Davide Calabro
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid