5,427,813 members and growing! (17,873 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Tools with source code     Intermediate License: The Code Project Open License (CPOL)

XTimer - Timer and Stopwatch Utility with Source Code

By Hans Dietrich

XTimer provides countdown timer and stopwatch features in a compact MFC dialog app.
VC6, C++Windows, Win2K, WinXP, MFC, VS6, Visual Studio, Dev

Posted: 29 May 2003
Updated: 20 Aug 2007
Views: 66,639
Bookmarked: 44 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
29 votes for this Article.
Popularity: 6.69 Rating: 4.58 out of 5
1 vote, 3.4%
1
1 vote, 3.4%
2
1 vote, 3.4%
3
6 votes, 20.7%
4
20 votes, 69.0%
5

Introduction

XTimer is a useful tool for measuring time durations - for example, if you want to measure how long it takes for a program to run. XTimer offers these features:

  • Countdown timer - counts down (like a microwave oven timer) from some HH:MM:SS value to zero.
  • Stopwatch - continuously counts up until stopped.
  • Play a wav file - when the countdown timer expires, XTimer will optionally play a wav file.
  • Compact size - takes very little space on the desktop.
  • Play once/Play until stopped - play the sound only once, or play it continuously (every 30 seconds) until the Stop button is clicked.

XTimer User Interface

Main Window

screenshot

There are three buttons on the main window: Start, which starts the timer/stopwatch and then changes to Stop; Reset, which sets the timer back to the zero position; and More, which displays the context menu (the context menu is also displayed by right-clicking on the window).

Context Menu

screenshot

The context menu allows you to choose the XTimer mode - stopwatch or countdown timer. When you change mode, the XTimer caption changes to reflect the mode you have set. You can also access the Timer Options Dialog.

The Quick Timer sub-menu allows you to choose a time for the countdown timer, and will also automatically start the timer.

Timer Options Dialog

screenshot

The Timer Options Dialog allows you to set the countdown time and the wav file to be played when the timer expires. If the Play Countdown Timer Sound is checked but no wav file is selected, XTimer will play its default sound. To completely disable all sounds, uncheck Play Countdown Timer Sound.

You can choose to play the sound only once, or play it continuously (every 30 seconds) until the Stop button is clicked. If the Play until stopped option is selected, the caption will change to XTimer [TIMER+].

Using XTimer

XTimer.exe is self-contained and needs no other files (besides the standard MFC and system DLLs). After selecting the mode (and for the timer, the countdown time and sound options), click Start. The stopwatch/timer will begin running, and the Start button will change to Stop. If you click on the Stop button, it will change back to Start and the timer will stop running. The display will hold the last value displayed and will continue from the last value if you click on the Start button.

XTimer saves its settings to the registry in HKEY_CURRENT_USER\Software\CodeProject\XTimer.

Acknowledgments

Revision History

Version 1.3 - 2007 August 11

  • Save program options in registry
  • Left double-click on time display opens options dialog
  • Added Quick Timer sub-menu
  • Added VS2005 project

Version 1.2 - 2003 June 16

  • Fixed display bug reported by Pit M.

Version 1.1 - 2003 June 14

  • Added "Play once, Play until stopped" option

Version 1.0 - 2003 June 1

  • Initial public release

Usage

This software is released into the public domain. You are free to use it in any way you like, except that you may not sell this source code. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Hans Dietrich


Mvp
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.

Recently, I have moved to Los Angeles where I am doing consulting and development work.

Occupation: Software Developer (Senior)
Location: United States United States

Other popular Applications & Tools articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 16 of 16 (Total in Forum: 16) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralShow in TaskBarmemberPriyank Bolia22:19 29 Aug '07  
GeneralTray Icon suggestion [modified]supporteryarp23:13 21 Aug '07  
GeneralBut Hans! My tea needs 3 minutes, no more, no less!supporterpeterchen3:32 21 Aug '07  
GeneralRe: But Hans! My tea needs 3 minutes, no more, no less!mvpHans Dietrich11:40 21 Aug '07  
GeneralExcellent jobmembertnov6:02 12 Jul '07  
GeneralNew Features [modified]memberBassam Abdul-Baki9:30 3 Mar '07  
GeneralFeatures Request...!memberana_v12318:13 27 Sep '06  
GeneralRe: Features Request...!memberKJJ24:18 7 Nov '06  
GeneralStopwatch for Borland c++memberahidehude10:03 20 Sep '05  
Generalgood jobsussAnonymous3:48 30 Oct '04  
GeneralReally Good work :-)memberPit M.21:00 16 Jun '03  
GeneralRe: Really Good work :-)memberHans Dietrich22:02 16 Jun '03  
GeneralRe: Really Good work :-)memberPit M.23:30 16 Jun '03  
GeneralRe: Really Good work :-)memberHans Dietrich3:05 17 Jun '03  
GeneralRe: Really Good work :-)memberPit M.3:39 17 Jun '03  
GeneralCool... Good ideamemberJoel Holdsworth22:45 30 May '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Aug 2007
Editor: Deeksha Shenoy
Copyright 2003 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2008
Web10 | Advertise on the Code Project