Click here to Skip to main content
12,898,500 members (60,877 online)
Click here to Skip to main content

Stats

136.1K views
5.8K downloads
81 bookmarked
Posted 29 May 2003

XTimer - Timer and Stopwatch Utility with Source Code

, 20 Aug 2007 CPOL
XTimer provides countdown timer and stopwatch features in a compact MFC dialog app.
src
alarm1.wav
app.manifest
hans.ico
hightime.inl
more.ico
play.ico
playd.bmp
playu.bmp
reset.ico
start.ico
stop.ico
vs2005
vs6
Release
XTimer.exe
XTimer.dsp
XTimer.dsw
wav files
4beeps.wav
alarm1.wav
alarm2.wav
alarmclock.wav
alert.wav
beeps.wav
bell.wav
buzzer.wav
chirp.wav
ding.wav
dingdong.wav
fanfare.wav
gong.wav
ohoh.wav
onebell.wav
quackquack.wav
ringer.wav
the_timer_has_expired_f.wav
the_timer_has_expired_m.wav
trumpet.wav
alarmclock.wav
alert.wav
buzzer.wav
divedive.wav
europolice.wav
quackquack.wav
siren.wav
// XTimerDlg.h  Version 1.3 - article available at http://www.codeproject.com/tools/xtimer.asp
//
// Author:  Hans Dietrich
//          hdietrich@gmail.com
//
// License:
//     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.
//
//     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.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef XTIMERDLG_H
#define XTIMERDLG_H

#include "StaticCounter.h"
#include "hightime.h"
#include "BtnST.h"

//=============================================================================
class CXTimerDlg : public CDialog
//=============================================================================
{
// Construction
public:
	CXTimerDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CXTimerDlg)
	enum { IDD = IDD_XTIMER_DIALOG };
	CStaticCounter	m_Time;
	CButtonST		m_btnStart;
	CButtonST		m_btnReset;
	CButtonST		m_btnMore;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CXTimerDlg)
protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON			m_hIcon;
	CBrush			m_brush;
	CHighTime		m_StartTime;
	int				m_nTimerSeconds;		// used in timer mode - no. of 
											// seconds for timer to run
	CString			m_strSoundFile;
	BOOL			m_bTimerStarted;		// timer is running - used for 
											// context menu display
	BOOL			m_bTimer;				// TRUE = countdown timer mode
											// FALSE = stopwatch mode
	BOOL			m_bPlaySound;			// TRUE = play sound file or play 
											// default sound
	int				m_nPlayOnce;			// 0 = play sound once;
											// 1 = play sound until stopped
	BOOL			m_bContinuousPlay;		// TRUE = in continuous play mode
	CHighTimeSpan	m_TimeLeft;				// for timer
	CHighTimeSpan	m_TimeElapsed;			// for stopwatch

	void	LoadMenu(CPoint point);
	void	LoadProfile();
	void	PlaySoundFile();
	void	Reset();
	void	RestoreWindowPos(HWND hWnd, LPCTSTR lpszEntry);
	void	SaveProfile();
	void	SaveWindowPos(HWND hWnd, LPCTSTR lpszEntry, UINT nShowCmd);
	void	SetWindowText();

	// Generated message map functions
	//{{AFX_MSG(CXTimerDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	afx_msg void OnStart();
	afx_msg void OnStop();
	afx_msg void OnReset();
	afx_msg void OnAbout();
	afx_msg void OnMore();
	afx_msg void OnXTimer();
	afx_msg void OnStopwatch();
	afx_msg void OnTimerOptions();
	afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
	afx_msg void OnDestroy();
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	//}}AFX_MSG
	afx_msg void OnQuickTimer(UINT nID);

	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif //XTIMERDLG_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

Hans Dietrich
Software Developer (Senior) Hans Dietrich Software
United States United States
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.

For consulting and custom software development, please see www.hdsoft.org.






You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 20 Aug 2007
Article Copyright 2003 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid