Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

XTimer - Timer and Stopwatch Utility with Source Code

, 20 Aug 2007
XTimer provides countdown timer and stopwatch features in a compact MFC dialog app.
xtimer_demo.zip
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
xtimer_sounds.zip
// XButtonXP.h  Version 1.2
//
// Author:  Hans Dietrich
//          hdietrich@gmail.com
//
// 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  XBUTTONXP_H 
#define  XBUTTONXP_H 

#include "uxtheme.h"
#include "OddButton.h"

/////////////////////////////////////////////////////////////////////////////
// CXButtonXP window

class CXButtonXP : public COddButton
{
// Construction
public:
	CXButtonXP();
	virtual ~CXButtonXP();

// Attributes
public:
	enum ICON_ALIGNMENT
	{
		CENTER = 0,
		LEFT,
		RIGHT
	};

	void SetIconAlignment(ICON_ALIGNMENT ia) 
	{ 
		m_eIconAlignment = ia; 
		RedrawWindow();
	}
	BOOL GetToggle() { return m_bIsToggle; }
	void SetToggle(BOOL bIsToggle) 
	{ 
		m_bIsToggle = bIsToggle;
		m_bToggled  = FALSE;
		RedrawWindow();
	}
	BOOL GetToggleState() { return m_bToggled; }
	void SetToggleState(BOOL bToggled) { m_bToggled = bToggled; RedrawWindow(); }
	void EnableTheming(BOOL bEnable) 
	{ 
		m_bEnableTheming = bEnable; 
		if (m_bEnableTheming)
		{
			TRACE(_T("Theming will be enabled only on XP and only ")
				  _T("if the app is themed with a manifest file.\n"));
		}
		RedrawWindow();
	}
	BOOL IsThemed();


// Operations
public:
	void SetIcon(UINT nIDResource, ICON_ALIGNMENT ia = LEFT);
	void SetIcon(HICON hIcon, ICON_ALIGNMENT ia = LEFT);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CXButtonXP)
public:
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
protected:
	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
protected:
	void DrawIcon(CDC *pDC, 
				  BOOL bHasText, 
				  RECT& rectItem, 
				  RECT& rectText, 
				  BOOL bIsPressed, 
				  BOOL bIsDisabled);

	void PrepareImageRect(BOOL bHasText, 
						  RECT& rectItem, 
						  RECT& rectText, 
						  BOOL bIsPressed, 
						  DWORD dwWidth, 
						  DWORD dwHeight, 
						  RECT& rectImage);


	BOOL			m_bFirstTime;
	BOOL			m_bMouseOverButton;
	HTHEME			m_hTheme;
	HICON			m_hIcon;
	ICON_ALIGNMENT	m_eIconAlignment;
	BOOL			m_bToggled;
	BOOL			m_bIsToggle;
	BOOL			m_bLButtonDown;
	BOOL			m_bSent;
	BOOL			m_bEnableTheming;

	// Generated message map functions
	//{{AFX_MSG(CXButtonXP)
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnTimer(UINT nIDEvent);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

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

#endif // XBUTTONXP_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)

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.






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