Click here to Skip to main content
13,352,157 members (74,407 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 30 Jun 2004

Multi Clock

, 30 Jun 2004
Rate this:
Please Sign up or sign in to vote.
An article on mutliple clock displays


This Dialog based Application displays several different styles of clocks, analog, binary, decimal and nixie.


The Nixie tube was used in electronic instruments mainly in the 1960's thru 1980's. It is a neon filled vacuum tube that has 10 elements that can make the neon glow when any one element is grounded. The tube has a common anode with approx. 175 volts dc applied to it. I think it makes a cool clock.

Using the code

Several methods used in this code are borrowed from other programmers, some from this site (see Credits). The heart of the binary clock is the function

_itoa(nTime, ibuff, 2); 
where nTime is any integer containing the hour, minute or second. ibuff is a char buffer and the 2 is a base, in this case, binary.

The code to display a simple Decimal clock in the Windows Title Bar.

void CMultiClockDlg::DisplayDecimal()
  // Get the current time
  CTime time = CTime::GetCurrentTime();
  int nSecond = time.GetSecond();
  int nMinute = time.GetMinute();
  int nHour   = time.GetHour();
  if (nHour > 12)
    nHour -= 12;
  CString szStr;
  szStr.Format("MultiClock - %.2d:%.2d:%.2d", nHour, nMinute, nSecond);
  ::SetWindowText(m_hWnd, szStr);

Points of Interest

The Binary display is grouped, 4 bits for the hour, and 6 bits for the minutes and seconds. I did this because the hour can only be "01" thru "C" and the minutes/seconds "00" thru "3B". The nixie clock uses bitmaps (45X64) for each digit which are displayed by calling:
void CMultiClockDlg::FormatTm(CDC *pDC, int nTime, int nPos)
  int x, y;
  x = 8 +(m_bmp.GetWidth() * nPos);
  y = 8;
  switch (nTime)
    case 0:
      m_bmp.DrawDIB(pDC, x, y);

One thing I found writing this code, DO NOT USE: CDC *pDC = GetDC(); in a loop without using RelaseDC(pDC);

My first version would run for 15 to 20 minutes and crash because GetDC() uses 4 bytes of memory every time it is called.


  • ClockCtrl - The Analog Clock; Author: P.J. Naughter
  • Dib256 - Load Resource/Paint Bitmap, DibPal; Author: Jorg Konig


  • Version 1.0


Any comments or suggestion are welcome.


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

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralSome nixies ! Pin
Kochise3-Jul-04 10:56
memberKochise3-Jul-04 10:56 
GeneralBug... Pin
Ravi Bhavnani1-Jul-04 4:40
memberRavi Bhavnani1-Jul-04 4:40 
GeneralRe: Bug... Pin
Roger651-Jul-04 5:24
memberRoger651-Jul-04 5:24 
GeneralNice Pin
emilio_grv1-Jul-04 2:46
memberemilio_grv1-Jul-04 2:46 
GeneralRe: Nice Pin
Steve Mayfield1-Jul-04 12:20
memberSteve Mayfield1-Jul-04 12:20 
GeneralRe: Nice Pin
emilio_grv1-Jul-04 22:22
memberemilio_grv1-Jul-04 22:22 

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 | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 1 Jul 2004
Article Copyright 2004 by Roger65
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid