Slider Control)

Source: Internet
Author: User

All controls are created on the same path;

Step 1: Create a csliderctrl Class Object in. h;

Csliderctrl m_ctrlslider;

Step 2: Initialize the control using the void cmydlg: dodataexchange (cdataexchange * PDX) function in. cpp; // initialize the control

Void cmydlg: dodataexchange (cdataexchange * PDX)

{

// This function is used to exchange data between controls and class members.

Cdialog: dodataexchange (PDX );

// Special slider

Ddx_control (PDX, idc_slider1, m_ctrlslider );

}

Step 3: Set initialization in the bool cmydlg: oninitdialog () function; // set Initialization

Bool cmydlg: oninitdialog ()

{

Cdialog: oninitdialog ();

.........

M_ctrlslider.setrange (0,100); // you can specify the maximum and minimum values of the slider position.

M_ctrlslider.setpos (30); // you can specify the default position of the slider.

}

Step 3: Add event processing functions;

After initialization, add an event processing function to obtain the corresponding data when adjusting the slider position;

Add function declaration in 1.h

Afx_msg void onnmcustomdrawslider1 (nmhdr * pnmhdr, lresult * presult );

2. Add a message:

Begin_message_map (cmydlg, cdialog)

.........

On_notify (nm_customdraw, idc_slider1, onnmcustomdrawslider1)

.........

3. function definition; // This function is called through (2) when the slider is adjusted;

// Main Window Slider

Void cmydlg: onnmcustomdrawslider1 (nmhdr * pnmhdr, lresult * presult)

{

Int NPOs = m_ctrlslider.getpos (); // obtain the current position of the slider

// Make another edit box to display the adjusted data;

Cstring STR = _ T ("");

Str. Format (_ T ("% d %"), NPOs );

Setdlgitemtext (idc_edit13, STR );

}

Complete

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.