SkinEdit.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. #include "SkinUI.h"
  3. #include "ISkinControl.h"
  4. class SKINUI_CLASS CSkinEdit : public CEdit,public ISkinControl
  5. {
  6. DECLARE_DYNAMIC(CSkinEdit)
  7. //资源定义
  8. protected:
  9. CImageEx * m_pBackImgN; //正常资源
  10. CImageEx * m_pBackImgH; //高亮资源
  11. CImageEx * m_pIconImg; //图标资源
  12. BOOL m_bFocus, m_bPress, m_bHover, m_bMouseTracking; //状态变量
  13. int m_nIconWidth; //图标宽度
  14. bool m_bHandCursor; //手型鼠标
  15. CString m_strDefText; //默认文本
  16. BOOL m_bIsDefText; //默认状态
  17. TCHAR m_cPwdChar; //密码字符
  18. CPoint m_ptClient; //客户区
  19. public:
  20. CSkinEdit();
  21. virtual ~CSkinEdit();
  22. //资源加载
  23. public:
  24. //正常背景
  25. BOOL SetBackNormalImage(LPCTSTR lpszFileName, CONST LPRECT lpNinePart = NULL);
  26. //高亮背景
  27. BOOL SetBackHotImage(LPCTSTR lpszFileName,CONST LPRECT lpNinePart = NULL);
  28. //图标资源
  29. BOOL SetIconImage(LPCTSTR lpszFileName,bool bHandCursor = false);
  30. //设置函数
  31. public:
  32. //默认文本
  33. void SetDefaultText(LPCTSTR lpszText);
  34. //默认模式
  35. void SetDefaultTextMode(BOOL bIsDefText);
  36. //图标位置
  37. void GetIconRect( RECT &lprcIcon );
  38. //客户区起始坐标
  39. void SetClientPoint(CPoint pt);
  40. //重载函数
  41. public:
  42. //创建窗口
  43. virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  44. //设置属性
  45. virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  46. //设置属性
  47. virtual void ParseItem(CXmlNode *root);
  48. //创建控件
  49. virtual BOOL CreateControl(CWnd* pParentWnd);
  50. //消息映射
  51. public:
  52. //计算大小
  53. afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  54. //重绘非客户区
  55. afx_msg void OnNcPaint();
  56. //重绘背景
  57. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  58. //左键按下
  59. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  60. //左键抬起
  61. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  62. //鼠标移动
  63. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  64. //鼠标离开
  65. afx_msg LRESULT OnMouseLeave(WPARAM wparam, LPARAM lparam);
  66. //控件销毁
  67. afx_msg void OnDestroy();
  68. //获取焦点
  69. afx_msg void OnSetFocus(CWnd* pOldWnd);
  70. //失去焦点
  71. afx_msg void OnKillFocus(CWnd* pNewWnd);
  72. //鼠标样式
  73. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  74. //颜色反映射
  75. afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
  76. //点击测试
  77. afx_msg LRESULT OnNcHitTest(CPoint point);
  78. //非客户区左键抬起
  79. afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  80. protected:
  81. DECLARE_MESSAGE_MAP()
  82. };
  83. //////////////////////////////////////////////////////////////////////////
  84. class SKINUI_CLASS CMultiSkinEdit : public CSkinEdit
  85. {
  86. DECLARE_DYNAMIC(CMultiSkinEdit)
  87. public:
  88. CMultiSkinEdit(){}
  89. virtual ~CMultiSkinEdit(){}
  90. //重载函数
  91. public:
  92. //创建控件
  93. virtual BOOL CreateControl(CWnd* pParentWnd);
  94. protected:
  95. DECLARE_MESSAGE_MAP()
  96. };