123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #ifndef BUTTON_HEAD_FILE
- #define BUTTON_HEAD_FILE
- #include "ImageEx.h"
- #include "RenderManager.h"
- #pragma once
- // 当前按钮是图片适应按钮大小;
- // 可以设置按钮来适应图片大小;
- //按妞类型
- enum UI_BUTTON_TYPE
- {
- en_PushButton,
- en_CheckButton,
- en_RadioButton,
- en_IconButton,
- en_MenuButton
- };
- // CButtonEx
- class CSkinButton : public CButton
- {
- DECLARE_DYNAMIC(CSkinButton)
- //资源定义
- public:
- // 4态背景;
- CImageEx* m_pBackImgN;
- CImageEx* m_pBackImgH;
- CImageEx* m_pBackImgD;
- CImageEx* m_pBackImgF;
- // 勾选框状态;
- CImageEx* m_pCheckImgN;
- CImageEx* m_pCheckImgH;
- CImageEx* m_pCheckImgTickN;
- CImageEx* m_pCheckImgTickH;
- // 箭头和图标;
- CImageEx * m_pArrowImg, * m_pIconImg;
-
- //变量定义
- protected:
- BOOL m_bFocus, m_bPress, m_bHover, m_bMouseTracking;
- UI_BUTTON_TYPE m_nBtnType;
- HMENU m_hMenu;
- HDC m_hBackDC;
- HFONT m_Font;
- DWORD m_dwTextAlign;
- //COLORREF m_colDefText; //默认文字
- COLORREF m_colNormalText; //正常文字
- COLORREF m_colSelectText; //高亮文字
- COLORREF m_colDisableText; //失效文字
- COLORREF m_colReadOnlyText; //只读文字
- BOOL m_bTransparent;
- HDC m_hParentDC;
- //函数定义
- public:
- //构造函数
- CSkinButton();
- //析构函数
- virtual ~CSkinButton();
- //重载函数
- protected:
- //消息循环
- virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- //设置函数
- public:
- //设置类型
- void SetButtonType(UI_BUTTON_TYPE type);
- //调整位置
- void SetSize(int nWidth,int nHeight);
- //设置菜单
- void SetMenu(HMENU hMenu);
- //获取字体
- HFONT GetCtrlFont(){return m_Font;};
- //矩形居中
- void CalcCenterRect(RECT& rcDest, int cx, int cy, RECT& rcCenter);
- //绘制背景
- void DrawParentWndBg(HWND hWnd,HDC hDC);
- //设置背景
- void SetParentBack(HDC hDC){ m_bTransparent = true; m_hParentDC = hDC;}
- //资源加载
- public:
- //设置资源
- BOOL SetBackImage(LPCTSTR lpNormal, LPCTSTR lpHoven, LPCTSTR lpDown, LPCTSTR lpFocus,CONST LPRECT lprcNinePart=NULL);
- //设置资源
- BOOL SetCheckImage(LPCTSTR lpNormal, LPCTSTR lpHoven, LPCTSTR lpTickNormal, LPCTSTR lpTickHoven);
- //设置资源
- BOOL SetIconImage(LPCTSTR lpszFileName);
- //设置资源
- BOOL SetMenuImage(LPCTSTR lpszFileName);
- //绘画函数
- public:
- //PUSH按钮
- void DrawPushButton(CDC* pDC,RECT &rcClient);
- //Check按钮
- void DrawCheckButton(CDC* pDC,RECT &rcClient);
- //Check按钮
- void DrawIConButton(CDC* pDC,RECT &rcClient);
- //Check按钮
- void DrawMenuButton(CDC* pDC,RECT &rcClient);
- //消息函数
- protected:
- //鼠标移动
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- //鼠标离开
- afx_msg LRESULT OnMouseLeave(WPARAM wparam, LPARAM lparam);
- //重绘背景
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- //销毁消息
- afx_msg void OnDestroy();
- //左键按下
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- //左键抬起
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- //设置焦点
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- //焦点丢失
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- //绘制消息
- afx_msg void OnPaint();
- //左键双击
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- protected:
- DECLARE_MESSAGE_MAP()
- };
- #endif
|