Rotate button (fine-tune button): the corresponding control class is cspinbuttonctrl
Progress bar: the corresponding control class is cprogressctrl
Slider: the corresponding control class is csliderctrl
The operations on these three controls are performed in the same way as the control classes associated with them, and these three controls have great similarity, so they are put together here.
First, let's get to know:
Spin: Progress: slider:
Common functions:
Setrange ()/getrange (); // set and obtain the range expressed by the control/* set the increment (step size) of the control */cspinbuttonctrl: setaccel cprogressctrl: setstep cslierctrl :: setpagesize csliderctrl: setlinesize setpos ()/getpos (); // you can set and obtain the current value.
In addition, the rotation button is usually used with the edit box, so you need to set the partnership between the two before use.
Use Case columns:
The Association settings of the spin control and the edit box control are as follows: Check: Auto Buddy and set buddy interger
The program interface settings are as follows:
To facilitate control operations: the following control types are associated with the progress, Slider, and spin controls: m_wndprogress, m_wndslider, and m_wndspin.
The specific functions are shown as follows:
/************************************ Initialize the control function **************************************/ void cctrl4dlg:: initctrl () {// set the value range of the control to m_wndspin.setrange (0,100); m_wndprogress.setrange (0,100); m_wndslider.setrange (0,100); // set the control's step to udaccel accel = {0 }; accel. nsec = 1; // set to hold down the accel for several seconds to start to fast-forward. ninc = 1; // growth rate m_wndspin.setaccel (1, & accel); m_wndprogress.setstep (10); m_wndslider.setlinesize (5); // you can specify the increment of cursor (20) for mouse clicks and cursor buttons ); // set the increment of the keyboard flip button // set the value of each scale. You need to check "tic marks" and "auto tics" style m_wndslider.setticfreq (20) in the slider control );}
/*************************************** * ****************** "Growth" button message response function ************* **************************************** * *****/void cctrl4dlg:: onbtnadd () {// todo: add your control notification handler code here // progress bar one step forward m_wndprogress.stepit (); // obtain the current position of the progress bar int NPOs = m_wndprogress.getpos (); // set the obtained parameters to slider and spinm_wndslider.setpos (NPOs); m_wndspin.setpos (NPOs );}
/*************************************** **************************************** * The message response function of the slider nm_customdraw, when you drag a slider, set the position of the progress and spin ***************************** **************************************** * ***********/void cctrl4dlg:: oncustomdrawslider (nmhdr * pnmhdr, lresult * presult) {// todo: add your control notification handler code here // get the current position of the slider int NPOs = m_wndslider.getpos (); // set the obtained parameters to progress and spinm_wndprogress.setpos (NPOs); m_wndspin.setpos (NPOs); * presult = 0 ;}
Demo: Click to open the link