#pragma once ////////////////////////////////////////////////////////////////////// // CPropertyGridItemSize is a CPropertyGridItem derived class. // It is used to create size-value item in a Property Grid control. // class CPropertyGridItemSubSelect : public CPropertyGridItem { public: // Constructs a CPropertyGridItemSize object. // CPropertyGridItemSubSelect( // Caption of the item. CString strCaption, HWND hNotifyWnd, UINT nNotifyMsg, // Initial value BOOL bValue = FALSE); // Constructs a CPropertyGridItemSize object. // CPropertyGridItemSubSelect( // Identifier of the item. UINT nID, // HWND hNotifyWnd, UINT nNotifyMsg, // Initial value BOOL bValue = FALSE); // Destroys a CPropertyGridItemSize object. // virtual ~CPropertyGridItemSubSelect(void); private: class CPropertyGridItemSubSelectColor; class CPropertyGridItemSubSelectString; HWND m_hNotifyWnd; // 接收自定义消息的窗口句柄 UINT m_nNotifyMsg; // 自定义消息 CString m_strDescription; COLORREF m_clrValue; BOOL m_bValue; BOOL* m_pBindBool; // 绑定到属性项的CSize对象 CPropertyGridItemSubSelectColor* m_itemColor; CPropertyGridItemSubSelectString* m_itemString; public: // Call this method to change item's value // void SetBool( // The new Size value of the item. BOOL bValue); // Call this method to get the size value of the item. // CSize GetBool(); // 把一个CSize对象绑定到属性项 void BindToBool(BOOL* pBindBool) { m_pBindBool = pBindBool; if (m_pBindBool) SetBool(*m_pBindBool); } private: void _Init(BOOL bValue); void SetColor(COLORREF clr); void SetString(CString strName); //CString SizeToString(CSize size); //CSize StringToSize(CString str); virtual void OnAddChildItem(); virtual void SetValue(CString strValue); void UpdateChilds(); friend class CPropertyGridItemSubSelectColor; friend class CPropertyGridItemSubSelectString; }; ////////////////////////////////////////////////////////////////////// AFX_INLINE CSize CPropertyGridItemSubSelect::GetBool() { return m_bValue; }