// Timer.h: interface for the CTimer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_TIMER_H__7DD98D22_AE28_11D2_B7C8_444553540000__INCLUDED_)
#define AFX_TIMER_H__7DD98D22_AE28_11D2_B7C8_444553540000__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#define WM_MM_TIMER		(WM_USER + 0x220)

class CTimer  
{
public:
	CTimer();
	virtual ~CTimer();

// Oprations
public:
	BOOL Start(HWND hWnd, UINT uDelay, UINT uResolution = 0, UINT fuEvent = TIME_PERIODIC);
	void Stop();

	inline UINT GetID()	{	return m_uTimerID;	}

protected:
	HWND     m_hWnd;
	TIMECAPS m_timeCaps;
	UINT     m_uTimerRes;
	UINT     m_uTimerID;

	BOOL	 m_bTimerInited;
	BOOL	 m_bTimerStarted;

// Attributes
public:
	static void CALLBACK TimeProc(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);  

// Oprations for count time and report
public:
	void StartCount();
	void StopCountAndReport(BOOL bWithMsgBox = FALSE);

	inline CString GetReport()	{	return m_strReport;	}
	inline int GetCount()	{	return m_iStopCount - m_iStartCount;	}

protected:
	int m_iStartCount;
	int m_iStopCount;
	CString m_strReport;
};

#endif // !defined(AFX_TIMER_H__7DD98D22_AE28_11D2_B7C8_444553540000__INCLUDED_)
