Cool Rolling Clock Control

Overview

This is a Clock control  which is able to roll the digit away as the time elapses, just like what the oil meter does in the old car.

This is a control derived from the CStatic, it's inspired by the code of Mr. Mark Findlay for his "Scrolling credits dialog". However,

a lot was rewritten. I only focus on the rolling part of the code, and didn't provide the interface of the color (Bk&Text), although providing 

those stuff looks like more professional. But that would be easy for you guys  if you like, as well as the font. :-)

Using the Rolling Clock Control

  1. Insert the file RollingClk.h and RollingClk.cpp into your project
  2. Create a dialog in your project. Drag a static control from the control panel; setting it to a reasonable size;
  3. In the dialog's header file, add the following line
    	
    // I supposed that you add the file to the same path of 
    // the project, or you have to 
    #include "rollingClk.h" 
    
    //include the whole path
    ...
    
    CRollingClk m_Static;
    
  4. In the OnInitDialog() of your Dialog class, add the following code
    // the "IDC_STATIC1" is the ID of your static control
    m_Static.SubclassDigItem(IDC_STATIC1,this); 
    
    // you can also set the first two parameters as 
    // text & Bk Color,
    m_Static.Start();  
    
    // and the third as the slipping speed, or nothing--it 
    // will choose the default values.
    And In the OnPaint() of Parent Dialog, you should add:
    else
    {
    ...
    // add here	
    m_Static.SetFirstTime(TRUE);
    CDialog::OnPaint();
    
So that when the Dialog thrives from minimum, the static will redraw. That's it!

Downloads

Download source - 4 Kb
Download demo project - 19 Kb


Comments

  • Minimized dialog box problem

    Posted by treeam on 11/15/2005 10:14am

    When I minimize the dialog box that I have the clock on and then restore the dialog box to its original size the clock display gets all messed up. I verified the same behavior with the example/demo code provided. Does anyone know how I can fix the problem?

    Reply
  • How do i do it in vb

    Posted by Legacy on 02/05/2003 12:00am

    Originally posted by: Cory

    how do i make this program or one like it in Visual Basic

    Reply
  • Clock rolls stangely...

    Posted by Legacy on 05/12/2002 12:00am

    Originally posted by: J

    Clock rolls stangely...
    The numbers change not depens on their position

    Reply
  • I want too

    Posted by Legacy on 05/12/2001 12:00am

    Originally posted by: david

    :)

    Reply
  • i have seen a lot better in none-visual compilers

    Posted by Legacy on 03/27/2001 12:00am

    Originally posted by: mario flores

    i think that you can make some changes thats all...but anyway its good...keep the good working

    Reply
  • Another approach

    Posted by Legacy on 03/21/2001 12:00am

    Originally posted by: Jim Musson

    I have modified the paint code with what I think is a simpler algorithm. Download http://www.musson.org/coolclock.zip for the source code.

    This is a great way to display the time, I really like it!

    Reply
  • It could be better

    Posted by Legacy on 03/16/2001 12:00am

    Originally posted by: Ionutz

    Your OnPaint() function is 250 lines long. Brake it. What's with all the if,else mumbo-jumbo. I cannot read this kind of code.

    Reply
  • Problem in Starting Clock

    Posted by Legacy on 03/15/2001 12:00am

    Originally posted by: Hamid Yaseen

    Dear Friend
    
    When I am checking your suppied example on Win98. The function start
    m_digital1.Start();
    is called from the fuction
    CCoolClockDlg::OnInitDialog();
    gives assertion failed.
    When I debugged the code of function start.It gives assertion at GetClientRect function.
    As line from your code is as
    GetClientRect(&m_SrollingRect);
    it gives assertion failed.
    Try to use any alternative GetClientRect or give any solid reason. If it works well the response me at my mail.
    ok
    best regard
    Hamid Yaseen

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • Available On-Demand Today's changing workforce dynamics, economic challenges, and technological advances are placing immense pressure on business leaders to turn their focus on people – their most valuable asset – in order to remain competitive. Research shows that a significant number of new employees quit within one year of taking a new job*. Whether it's through a merger and acquisition, or standard hiring process, like any first impression, early experiences shape their opinions of their new …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds