www.pudn.com > rsdagl.rar > ClockCtrl.h
#ifndef _CLOCKCTRL_H__
#define _CLOCKCTRL_H__
//时钟控件类:)完全盗别人的
class CClockCtrl : public CStatic
{
public:
CClockCtrl();
//Accessors
int GetHour() const { return m_nHour; };
int GetMinute() const { return m_nMinute; };
int GetSecond() const { return m_nSecond; };
BOOL GetRealTime() const;
BOOL GetShowHours() const { return m_bShowHours; };
BOOL GetShowMinutes() const { return m_bShowMinutes; };
BOOL GetShowSeconds() const { return m_bShowSeconds; };
BOOL GetShowPoints() const { return m_bShowPoints; };
BOOL GetShowMinorPoints() const { return m_bShowMinorPoints; };
COLORREF GetHourMinutesHandColor() const { return m_ColorHourMinutesHand; };
COLORREF GetBackgroundColor() const { return m_ColorBackground; };
BOOL Get3dPoints() const { return m_b3dPoints; };
//Mutators
void SetTime(int nHour, int nMinute, int nSecond);
void SetRealTime(BOOL bRealTime);
void SetShowHours(BOOL bShowHours);
void SetShowMinutes(BOOL bShowMinutes);
void SetShowSeconds(BOOL bShowSeconds);
void SetShowPoints(BOOL bShowPoints);
void SetShowMinorPoints(BOOL bShowMinorPoints);
void SetHourMinutesHandColor(COLORREF color);
void SetBackgroundColor(COLORREF color);
void Set3dPoints(BOOL b3dPoints);
protected:
enum HandType
{
HOUR,
MINUTE,
SECOND
};
//{{AFX_VIRTUAL(CClockCtrl)
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
//{{AFX_MSG(CClockCtrl)
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnDestroy();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
void RecalcLayout();
double MinuteToRadian(double minute);
CPoint ComputePoint(int nMinute, double ratio);
void DrawFacePoint(CDC& dc, const CPoint& point, BOOL bMajor);
void DrawHands(CDC& dc, int nHour, int nMinute, int nSecond, BOOL bDrawAll);
void DrawHand(CDC& dc, int nMinute, HandType type, BOOL bDraw);
void GetHandPoints(int nValue, HandType type, CPoint* pPoints);
//Member variables
COLORREF m_ColorHourMinutesHand;
COLORREF m_ColorPoints;
COLORREF m_ColorBackground;
CPoint m_MiddlePoint;
int m_nXRadius;
int m_nYRadius;
int m_nPointWidth;
int m_nHour;
int m_nMinute;
int m_nSecond;
UINT m_nTimerID;
BOOL m_bEnableRealtime;
BOOL m_bShowHours;
BOOL m_bShowMinutes;
BOOL m_bShowSeconds;
BOOL m_bShowPoints;
BOOL m_bShowMinorPoints;
BOOL m_b3dPoints;
DECLARE_MESSAGE_MAP()
};
#endif //_CLOCKCTRL_H__