PropertyGridItemSubSelect.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. //////////////////////////////////////////////////////////////////////
  3. // CPropertyGridItemSize is a CPropertyGridItem derived class.
  4. // It is used to create size-value item in a Property Grid control.
  5. //
  6. class CPropertyGridItemSubSelect : public CPropertyGridItem
  7. {
  8. public:
  9. // Constructs a CPropertyGridItemSize object.
  10. //
  11. CPropertyGridItemSubSelect(
  12. // Caption of the item.
  13. CString strCaption,
  14. HWND hNotifyWnd,
  15. UINT nNotifyMsg,
  16. // Initial value
  17. BOOL bValue = FALSE);
  18. // Constructs a CPropertyGridItemSize object.
  19. //
  20. CPropertyGridItemSubSelect(
  21. // Identifier of the item.
  22. UINT nID,
  23. //
  24. HWND hNotifyWnd,
  25. UINT nNotifyMsg,
  26. // Initial value
  27. BOOL bValue = FALSE);
  28. // Destroys a CPropertyGridItemSize object.
  29. //
  30. virtual ~CPropertyGridItemSubSelect(void);
  31. private:
  32. class CPropertyGridItemSubSelectColor;
  33. class CPropertyGridItemSubSelectString;
  34. HWND m_hNotifyWnd; // 接收自定义消息的窗口句柄
  35. UINT m_nNotifyMsg; // 自定义消息
  36. CString m_strDescription;
  37. COLORREF m_clrValue;
  38. BOOL m_bValue;
  39. BOOL* m_pBindBool; // 绑定到属性项的CSize对象
  40. CPropertyGridItemSubSelectColor* m_itemColor;
  41. CPropertyGridItemSubSelectString* m_itemString;
  42. public:
  43. // Call this method to change item's value
  44. //
  45. void SetBool(
  46. // The new Size value of the item.
  47. BOOL bValue);
  48. // Call this method to get the size value of the item.
  49. //
  50. CSize GetBool();
  51. // 把一个CSize对象绑定到属性项
  52. void BindToBool(BOOL* pBindBool)
  53. {
  54. m_pBindBool = pBindBool;
  55. if (m_pBindBool)
  56. SetBool(*m_pBindBool);
  57. }
  58. private:
  59. void _Init(BOOL bValue);
  60. void SetColor(COLORREF clr);
  61. void SetString(CString strName);
  62. //CString SizeToString(CSize size);
  63. //CSize StringToSize(CString str);
  64. virtual void OnAddChildItem();
  65. virtual void SetValue(CString strValue);
  66. void UpdateChilds();
  67. friend class CPropertyGridItemSubSelectColor;
  68. friend class CPropertyGridItemSubSelectString;
  69. };
  70. //////////////////////////////////////////////////////////////////////
  71. AFX_INLINE CSize CPropertyGridItemSubSelect::GetBool() {
  72. return m_bValue;
  73. }