PropertyGridExtItemMaskEdit.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #pragma once
  2. /////////////////////////////////////////////////////////////////////////////
  3. // CInplaceMaskEdit 内置格式化输入控件
  4. /////////////////////////////////////////////////////////////////////////////
  5. #include "MaskEdit.h"
  6. class CPropertyGridExtItemMaskEdit; // 前向引用
  7. class CInplaceMaskEdit : public CMaskEdit
  8. {
  9. public:
  10. CInplaceMaskEdit();
  11. virtual ~CInplaceMaskEdit();
  12. void SetValue(CString strValue);
  13. void Create(CPropertyGridExtItemMaskEdit* pItem, CRect rect);
  14. void DestroyItem();
  15. protected:
  16. CString m_strValue;
  17. CBrush m_brBack;
  18. COLORREF m_clrBack;
  19. CWnd* m_pGrid;
  20. CPropertyGridExtItemMaskEdit* m_pItem;
  21. protected:
  22. //{{AFX_VIRTUAL(CInplaceMaskEdit)
  23. //}}AFX_VIRTUAL
  24. virtual BOOL SelectConstraint(int nDirection, BOOL bCircle);
  25. //{{AFX_MSG(CInplaceMaskEdit)
  26. afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
  27. afx_msg void OnEnKillfocus();
  28. afx_msg void OnEnSetfocus();
  29. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  30. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  31. afx_msg UINT OnGetDlgCode();
  32. void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  33. //}}AFX_MSG
  34. DECLARE_MESSAGE_MAP()
  35. friend class CPropertyGridExtItemMaskEdit;
  36. };
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CPropertyGridExtItemMaskEdit 该属性表项使用格式化输入控件
  39. /////////////////////////////////////////////////////////////////////////////
  40. class CPropertyGridExtItemMaskEdit : public CPropertyGridItem
  41. {
  42. public:
  43. // 构造函数:
  44. // strCaption -属性名称
  45. // lpszMask -格式化输入的掩码字符串,例如“00.00”
  46. // lpszLiteral-格式化输入的literal字符串,例如“__.__”
  47. // lpszDefault-格式化输入的缺省字符串
  48. // chPrompt -格式化输入的提示字符
  49. // 注意:参数lpszLiteral和lpszDefault中出现的提示字符必须跟参数
  50. // chPrompt保持一致。
  51. CPropertyGridExtItemMaskEdit(CString strCaption, LPCTSTR lpszMask, LPCTSTR lpszLiteral, LPCTSTR lpszDefault = NULL, TCHAR chPrompt = _T('_'));
  52. // 构造函数:
  53. // nID -属性ID
  54. // lpszMask -格式化输入的掩码字符串,例如“00.00”
  55. // lpszLiteral-格式化输入的literal字符串,例如“__.__”
  56. // lpszDefault-格式化输入的缺省字符串
  57. // chPrompt -格式化输入的提示字符
  58. // 注意:参数lpszLiteral和lpszDefault中出现的提示字符必须跟参数
  59. // chPrompt保持一致。
  60. CPropertyGridExtItemMaskEdit(UINT nID, LPCTSTR lpszMask, LPCTSTR lpszLiteral, LPCTSTR lpszDefault = NULL, TCHAR chPrompt = _T('_'));
  61. virtual ~CPropertyGridExtItemMaskEdit();
  62. protected:
  63. virtual void OnSelect();
  64. virtual void OnValidateEdit();
  65. virtual void SetEditText(CString str);
  66. virtual BOOL OnChar(UINT nChar);
  67. virtual void OnLButtonDblClk();
  68. CInplaceMaskEdit m_wndMaskEdit; // 内置格式化输入控件
  69. CString m_strEditMask;
  70. CString m_strLiteral;
  71. CString m_strDefault;
  72. TCHAR m_chPrompt;
  73. friend class CInplaceMaskEdit;
  74. };