-
The following ** measured OK
The dialog oninitdialog message response function sets the range of the slider control to 0 100
:sendmessage(::getdlgitem(m_hwnd, idc_slider1), tbm_setrangemin, (wparam) true, (lparam)0);
:sendmessage(::getdlgitem(m_hwnd, idc_slider1), tbm_setrangemax, (wparam) true, (lparam)100);
Bind an int member variable to the edit control.
Add an en change message response function to the edit control.
void cmfcdlg2014dlg::onchangeedit1()
updatedata();edit changes, and the value shown on edit is flashed into m edt
sendmessage(::getdlgitem(m_hwnd, idc_slider1), tbm_setpos, (wparam) true, (lparam)m_edt);Then send a tbm setpos message to the slider and send the value to display.
Added the nm releasedcapture message response function to the slider widget (for mouse dragging).
void cmfcdlg2014dlg::onreleasedcaptureslider1(nmhdr* pnmhdr, lresult* presult)
m_edt = ::sendmessage(::getdlgitem(m_hwnd, idc_slider1), tbm_getpos, 0, 0);Send a TBM getpos message to the slider to get the position value of the slider.
updatedata(false);Then swipe to edit to display.
presult = 0;This behavior is generated by default by the MFC Class Wizard.
-
Overload the EN change message of the box, judge getfocus()==getDLGITEM(idc edit1), which means that the box is the input state (not set by the slider), getDLGITEMINT to get the value (or there are associated variables), judge the value range, if it is in a reasonable range, just set the slider.
-
You can write a short program by yourself!
-
The slider standard control is definitely an integer range.
If you don't overload the standard controls to make your own sliders, there's a roundabout way:
Do not use the standard display of the slider, assuming that the range set by the slider is 1000, the following use static or tip to make your own display, for example, the value is 456, then divide by 100 in **, static display can be, there is no other way too good.
-
The slider itself has a function that should be there. By calling this function, the slider can be sliding. If you have to click on the slider with the mouse, you can select CalssWizard in the View menu, select your own dialog class, in the right bar box, you can find WM Lbuttondown, add this function to the dialog class, you can directly call the function parameter point, you can get the x position of the mouse.
That's all for now, and you'll find out the rest.
-
Use onlbuttondown to get the location of the mouse click and move the slider to the relevant location.
-
There must be a way to do it. For example, setpos(。。 Wait, let's take a look at MSDN.
-
The properties of the slider itself don't necessarily have wm lbuttondown