1 #pragma once 2 // 这是一个带微调按钮的Edit控件,在CEdit右侧附加一个微调按钮,请预留空间 3 // CSpinEdit 4 5 class CSpinEdit : public CEdit 6 { 7 DECLARE_DYNAMIC(CSpinEdit) 8 9 public: 10 CSpinEdit(); 11 virtual ~CSpinEdit(); 12 13 void SetRange(short lower, short upper, short step = 1); // 设置文本框中的数值范围 14 void SetValue(int value); //设置文本框中的数值 15 int GetValue(); //获取文本框中的数值 16 void SetMouseWheelEnable(bool enable); //设置是否允许响应鼠标滚轮 17 18 protected: 19 CSpinButtonCtrl m_spin; //微调按钮控件 20 int m_step{}; 21 int m_spin_width{}; 22 bool m_mouse_wheel_enable{ true }; 23 24 DECLARE_MESSAGE_MAP() 25 virtual void PreSubclassWindow(); 26 public: 27 virtual BOOL PreTranslateMessage(MSG* pMsg); 28 protected: 29 afx_msg LRESULT OnTabletQuerysystemgesturestatus(WPARAM wParam, LPARAM lParam); 30 public: 31 void OnDeltaposSpin(NMHDR* pNMHDR, LRESULT* pResult); 32 afx_msg void OnKillFocus(CWnd* pNewWnd); 33 afx_msg void OnEnable(BOOL bEnable); 34 afx_msg void OnSize(UINT nType, int cx, int cy); 35 }; 36 37 38