VC + + implementation of sliding control

Source: Internet
Author: User
Tags definition bool function definition

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.