PropertyGridExtItemDegree.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #pragma once
  2. /////////////////////////////////////////////////////////////////////////////
  3. // CInplaceDegreeEdit
  4. /////////////////////////////////////////////////////////////////////////////
  5. #include "MaskEdit.h"
  6. class CPropertyGridExtItemDegree; // 前向引用
  7. class CInplaceDegreeEdit : public CDegreeEdit
  8. {
  9. public:
  10. // 构造函数:
  11. // nSecondPrecision-秒的小数部分的位数,范围0-3
  12. CInplaceDegreeEdit(int nSecondPrecision);
  13. virtual ~CInplaceDegreeEdit();
  14. void SetValue(CString strValue);
  15. void Create(CPropertyGridExtItemDegree* pItem, CRect rect);
  16. void DestroyItem();
  17. protected:
  18. CString m_strValue;
  19. CBrush m_brBack;
  20. COLORREF m_clrBack;
  21. CWnd* m_pGrid;
  22. CPropertyGridExtItemDegree* m_pItem;
  23. protected:
  24. //{{AFX_VIRTUAL(CInplaceDegreeEdit)
  25. //}}AFX_VIRTUAL
  26. virtual BOOL SelectConstraint(int nDirection, BOOL bCircle);
  27. //{{AFX_MSG(CInplaceDegreeEdit)
  28. afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
  29. afx_msg void OnEnKillfocus();
  30. afx_msg void OnEnSetfocus();
  31. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  32. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  33. afx_msg UINT OnGetDlgCode();
  34. void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  35. //}}AFX_MSG
  36. DECLARE_MESSAGE_MAP()
  37. friend class CPropertyGridExtItemDegree;
  38. };
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CPropertyGridExtItemDegree 该属性表项以度分秒方式输入和显示度,使用了格式化输入控件
  41. /////////////////////////////////////////////////////////////////////////////
  42. class CPropertyGridExtItemDegree : public CPropertyGridItem
  43. {
  44. public:
  45. // 构造函数:
  46. // strCaption -属性名称
  47. // fDegree -初始属性值,单位:度
  48. // nSecondPrecision-秒的小数部分的位数,范围0-3
  49. CPropertyGridExtItemDegree(CString strCaption, double fDegree = 0, int nSecondPrecision = 2);
  50. // 构造函数:
  51. // nID -属性ID
  52. // fDegree -初始属性值,单位:度
  53. // nSecondPrecision-秒的小数部分的位数,范围0-3
  54. CPropertyGridExtItemDegree(UINT nID, double fDegree = 0, int nSecondPrecision = 2);
  55. virtual ~CPropertyGridExtItemDegree();
  56. // 设置属性值:
  57. // fDegree-新的属性值,单位:度
  58. void SetDegree(double fDegree);
  59. // 获取属性值,返回值单位:度
  60. double GetDegree();
  61. // 把一个浮点变量绑定到属性项
  62. void BindToDegree(double* pBindDegree);
  63. protected:
  64. double m_fDegree; // 属性值,单位:度
  65. int m_nSecondPrecision; // 秒的小数部分的位数,范围0-3
  66. double* m_pBindDegree; // 绑定到属性项的浮点变量
  67. // 当属性值由于用户输入而改变时,调用此函数
  68. virtual void SetValue(CString strValue);
  69. virtual void OnSelect();
  70. virtual void OnValidateEdit();
  71. virtual void SetEditText(CString str);
  72. virtual BOOL OnChar(UINT nChar);
  73. virtual void OnLButtonDblClk();
  74. CInplaceDegreeEdit m_wndDegreeEdit;
  75. friend class CInplaceDegreeEdit;
  76. };