PushButton.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include "HJHomework.h"
  3. #include "ImageEx.h"
  4. class CPushButton : public CButton
  5. {
  6. DECLARE_DYNAMIC(CPushButton)
  7. public:
  8. CPushButton();
  9. virtual ~CPushButton();
  10. protected:
  11. BOOL m_bHover, m_bPress, m_bFocus, m_bSel, m_bMouseTracking; // 鼠标状态相关的变量
  12. BOOL m_bEnable, m_bFillet; // 控件状态
  13. DWORD m_btn_type; // 按钮类型
  14. COLORREF m_bkColor; // 背景颜色
  15. COLORREF m_fontcolor; // 字体颜色
  16. COLORREF m_bordercolor; // 边框颜色
  17. CImageEx* m_pImage; // 背景图片
  18. CFont m_font; // 文本字体
  19. UINT m_nRounded; // 圆角的大小
  20. DWORD m_dwStyle; // 按钮样式
  21. CString m_lpszText; // 按钮文本
  22. CImageEx* m_image; // 图片
  23. public:
  24. virtual void DrawTextButton(CDC* pDC, CRect& rcClient);
  25. virtual void DrawIconButton(CDC* pDC, CRect& rcClient);
  26. virtual void DrawBitmapButton(CDC* pDC, CRect& rcClient);
  27. virtual void DrawIconButton2(CDC* pDC, CRect& rcClient);
  28. void EnableWindow(BOOL bEnable = TRUE);
  29. void SetWindowText(LPCTSTR lpszString);
  30. void GetWindowText(CString& rString);
  31. protected:
  32. DECLARE_MESSAGE_MAP()
  33. public:
  34. virtual BOOL Create(CWnd* pParentWnd, UINT nID, CRect& rect, DWORD btnType, LPCTSTR lpszCaption,COLORREF bkColor = RGB(65,188,131),COLORREF fontColor = RGB(255,255,255), COLORREF bordercolor = NULL);
  35. virtual BOOL Create(CWnd* pParentWnd, UINT nID, CPoint& point, CSize& size, DWORD btnType, LPCTSTR lpszCaption,COLORREF bkColor = RGB(65,188,131),COLORREF fontColor = RGB(255,255,255), COLORREF bordercolor = NULL);
  36. afx_msg void OnPaint();
  37. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  38. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  39. afx_msg void OnMouseHover(UINT nFlags, CPoint point);
  40. afx_msg void OnMouseLeave();
  41. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  42. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  43. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  44. virtual void PreSubclassWindow();
  45. virtual BOOL PreTranslateMessage(MSG* pMsg);
  46. // 图标按钮的图标路径
  47. CString m_strPathIcon;
  48. // 用于画图板中该功能是否被选中,选中背景色为绿色,否则为白色
  49. BOOL m_bSelected;
  50. // 当画图板中某个功能被选择时,用于设置其背景色为绿色;当失去功能时,显示为白色
  51. void setBkColor(BOOL bSelected);
  52. void SetBkColor(COLORREF bk);
  53. };