#pragma once #include "HJHomework.h" #include "ImageEx.h" class CPushButton : public CButton { DECLARE_DYNAMIC(CPushButton) public: CPushButton(); virtual ~CPushButton(); protected: BOOL m_bHover, m_bPress, m_bFocus, m_bSel, m_bMouseTracking; // 鼠标状态相关的变量 BOOL m_bEnable, m_bFillet; // 控件状态 DWORD m_btn_type; // 按钮类型 COLORREF m_bkColor; // 背景颜色 COLORREF m_fontcolor; // 字体颜色 COLORREF m_bordercolor; // 边框颜色 CImageEx* m_pImage; // 背景图片 CFont m_font; // 文本字体 UINT m_nRounded; // 圆角的大小 DWORD m_dwStyle; // 按钮样式 CString m_lpszText; // 按钮文本 CImageEx* m_image; // 图片 public: virtual void DrawTextButton(CDC* pDC, CRect& rcClient); virtual void DrawIconButton(CDC* pDC, CRect& rcClient); virtual void DrawBitmapButton(CDC* pDC, CRect& rcClient); virtual void DrawIconButton2(CDC* pDC, CRect& rcClient); void EnableWindow(BOOL bEnable = TRUE); void SetWindowText(LPCTSTR lpszString); void GetWindowText(CString& rString); protected: DECLARE_MESSAGE_MAP() public: 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); 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); afx_msg void OnPaint(); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnMouseHover(UINT nFlags, CPoint point); afx_msg void OnMouseLeave(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); virtual void PreSubclassWindow(); virtual BOOL PreTranslateMessage(MSG* pMsg); // 图标按钮的图标路径 CString m_strPathIcon; // 用于画图板中该功能是否被选中,选中背景色为绿色,否则为白色 BOOL m_bSelected; // 当画图板中某个功能被选择时,用于设置其背景色为绿色;当失去功能时,显示为白色 void setBkColor(BOOL bSelected); void SetBkColor(COLORREF bk); };