PropertyGridItemNumber.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. //////////////////////////////////////////////////////////////////////
  3. // CPropertyGridItemNumber is a CPropertyGridItem derived class.
  4. // It is used to create integer value item in a Property Grid control.
  5. //
  6. class CPropertyGridItemNumber : public CPropertyGridItem
  7. {
  8. public:
  9. // Constructs a CPropertyGridItemNumber object.
  10. //
  11. CPropertyGridItemNumber(
  12. // Caption of the item.
  13. CString strCaption,
  14. // Initial value
  15. int nValue = 0);
  16. // Constructs a CPropertyGridItemNumber object.
  17. //
  18. CPropertyGridItemNumber(
  19. // Identifier of the item.
  20. UINT nID,
  21. // Initial value
  22. int nValue = 0);
  23. // Destroys a CPropertyGridItemNumber object.
  24. //
  25. virtual ~CPropertyGridItemNumber(void);
  26. private:
  27. int m_nValue;
  28. int* m_pBindNumber; // 绑定到属性项的整型变量
  29. BOOL m_bHasMinValue; // 标识是否有最小值
  30. BOOL m_bHasMaxValue; // 标识是否有最大值
  31. int m_nMinValue; // 属性项的最小值
  32. int m_nMaxValue; // 属性项的最大值
  33. public:
  34. // Call this method to change item's value
  35. //
  36. void SetNumber(
  37. // The new integer value of the item.
  38. int nValue);
  39. // Call this method to get the integer value of the item.
  40. //
  41. int GetNumber();
  42. // 把一个整型变量绑定到属性项
  43. void BindToNumber(int* pBindNumber)
  44. {
  45. m_pBindNumber = pBindNumber;
  46. if (m_pBindNumber)
  47. SetNumber(*m_pBindNumber);
  48. }
  49. // 设置属性项的最小值
  50. void SetMinNumber(int nMinValue);
  51. // 设置属性项的最大值
  52. void SetMaxNumber(int nMaxValue);
  53. protected:
  54. void _Init();
  55. virtual void SetValue(CString strValue);
  56. };
  57. //////////////////////////////////////////////////////////////////////
  58. AFX_INLINE int CPropertyGridItemNumber::GetNumber() {
  59. return m_nValue;
  60. }