⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clockctrl.h

📁 该时间管理是模仿酷派628手机上的时间管理书写其功能
💻 H
字号:
////////////////////////////////// Macros ///////////////////////////

#ifndef _CLOCKCTRL_H__
#define _CLOCKCTRL_H__



////////////////////////////////// Classes //////////////////////////

class CClockCtrl : public CStatic
{
public:
//Constructors / Destructors
  CClockCtrl();


  //设置时区(根据不同的时区设置显示不同的时间)
  void setTimeZoneDiffer(int iHourDiffer, int iMinuteDiffer);
 
  //是否显示时针
  void SetShowHours(BOOL bShowHours);
  
  //是否显示分针
  void SetShowMinutes(BOOL bShowMinutes);

  //是否显示秒针
  void SetShowSeconds(BOOL bShowSeconds);

  //是否取系统真实时间,TRUE:取系统时间 FLASE:不取系统真实时间
  void SetRealTime(BOOL bRealTime);
  
  //
  void SetShowPoints(BOOL bShowPoints);
  
  //
  void SetShowMinorPoints(BOOL bShowMinorPoints);
  
  //设置时针、分针的颜色
  void SetHourMinutesHandColor(COLORREF color);
  
  //设置钟表的背景颜色
  void SetBackgroundColor(COLORREF color);
  
  //是否支持3D效果
  void Set3dPoints(BOOL b3dPoints);

  //设置表时间
  void SetTime(int nHour, int nMinute, int nSecond);

  //是否是修改系统时间
  void SetTimerUpdate(BOOL isUpdateTime)
  {
	 m_bIsUpdate = isUpdateTime;
  }

//Accessors

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
  DECLARE_MESSAGE_MAP()

private:
	
	//设置钟表大小
	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);
	
	/////////////////////成员变量/////////////////////////////////
	//时针和分针的颜色
	COLORREF m_ColorHourMinutesHand;
	//钟表外观的表颜色
	COLORREF m_ColorPoints;
	//钟表背景色
	COLORREF m_ColorBackground;

	CPoint   m_MiddlePoint;
	//X半径
	int      m_nXRadius;
	//Y半径
	int      m_nYRadius;


	int      m_nPointWidth;

	//时间的小时、分、秒
	int      m_nHour;
	int      m_nMinute;
	int      m_nSecond;
	
	//当前设置的时区与标志时区的时差
	int      m_iTimeZoneDiffer;
	int      m_iMinuteDiffer;

	UINT     m_nTimerID;
	//是否取系统时间
	BOOL     m_bEnableRealtime;
	//是否显示小时、分、秒
	BOOL     m_bShowHours;
	BOOL     m_bShowMinutes;
	BOOL     m_bShowSeconds;

	
	BOOL     m_bShowPoints;
	BOOL     m_bShowMinorPoints;
	BOOL     m_b3dPoints;

	//是否是修改系统时间
	BOOL     m_bIsUpdate;

	//获取钟表上的时间:小时 
	int      GetHour() const { return m_nHour; };
	//获取钟表上的时间:分钟
	int      GetMinute() const { return m_nMinute; };
	//获取钟表上的时间:秒
	int      GetSecond() const { return m_nSecond; };
    //钟表是否使用系统时间
	BOOL     GetRealTime() const;
	//钟表是否显示秒针
	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
};

#endif //_CLOCKCTRL_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -