Sliding controls are one of the most commonly used controls in Windows. In general, it consists of a slider bar and an optional scale, which allows the user to display the corresponding value in the corresponding control by moving the slider. Typically, there must be a Label control or an edit box control near the sliding control to display the corresponding value. Sliding controls are widely used in applications, as you can see in the properties of the desktop. For this, let's take a look at how it is implemented.
(1) in VC + + 6.0 to create a new dialog box document project.
(2) Open Explorer, place an edit control in the dialog box, and place a slider control next to it. The basic framework has been completed.
(3) Right-click on the Slider control, select the "Create Class Wizard", and define a variable m_slider for the Slider control just now, the type is CSliderCtrl.
(4) The code bool Cmy601dlg::oninitdialog () is initialized in the dialog box, and the corresponding property is added. The following are common property-setting functions:
* Getrange,setrange function
Used to query and set the value range of the slider, default to 0~100. The function definition forms the following:
void GetRange (int &nmin,int &nmax) const;
void SetRange (int nmin,int nmax,bool bredrgetaw=false);
* Getpos,setpos function
Used to query and set the current value of the slider bar. The function definition forms the following:
int GetPos () const;
int setpos (int npos);
* Getlinesize,setlinesize function
Used to query and set the amount of movement of the slider when the right or left arrow is pressed, which defaults to 1 units. The function definition forms the following:
int getlinesize () const;
int setlinesize (int nsize);
* Getpagesize,setpagesize function
Used to query and set the function slider and block movement, which is the amount of movement of the slider when the PgUp or Pgdown is pressed. The function definition forms the following:
int getpagesize () const;
int setpagesize (int nsize);