PropertyGridItemBool.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. //////////////////////////////////////////////////////////////////////
  3. // CPropertyGridItemBool is a CPropertyGridItem derived class.
  4. // It is used to create Boolean-value item in a Property Grid control.
  5. //
  6. class CPropertyGridItemBool : public CPropertyGridItem
  7. {
  8. public:
  9. // Constructs a CPropertyGridItemBool object.
  10. //
  11. CPropertyGridItemBool(
  12. // Caption of the item.
  13. CString strCaption,
  14. // Initial value
  15. BOOL bValue = FALSE);
  16. // Constructs a CPropertyGridItemBool object.
  17. //
  18. CPropertyGridItemBool(
  19. // Identifier of the item.
  20. UINT nID,
  21. // Initial value
  22. BOOL bValue = FALSE);
  23. // Destroys a CPropertyGridItemBool object.
  24. //
  25. virtual ~CPropertyGridItemBool(void);
  26. // Call this method to change item's value
  27. //
  28. void SetBool(
  29. // The new BOOL-value of the item.
  30. BOOL bValue);
  31. // Call this method to get the Boolean value of the item.
  32. //
  33. BOOL GetBool();
  34. // 把一个布尔变量绑定到属性项
  35. void BindToBool(BOOL* pBindBool)
  36. {
  37. m_pBindBool = pBindBool;
  38. if (m_pBindBool)
  39. SetBool(*m_pBindBool);
  40. }
  41. protected:
  42. void SetValue(CString strValue);
  43. void _Init(BOOL bValue);
  44. private:
  45. BOOL m_bValue;
  46. BOOL* m_pBindBool; // 绑定到属性项的布尔变量
  47. };
  48. //////////////////////////////////////////////////////////////////////
  49. AFX_INLINE BOOL CPropertyGridItemBool::GetBool() {
  50. return m_bValue;
  51. }