MFC control (13): Progress Control and slider Control

Source: Internet
Author: User
Document directory
  • Usage example
Progress Control

When a time-consuming operation is in the process, the user is usually prompted, indicating that you are performing the operation, rather than stuck there. the most common prompt is the progress bar. in addition, the progress bar is generally used with timer, because it will be automatically refreshed if it is used.

Use timer see: http://blog.csdn.net/weiwenhp/article/details/8733216

 

In addition, the most important operations of progress control are as follows:

1. Specify the range, and use numbers. Just like in our system work progress, we need to specify a time, such as a week to deal with something.

2. Specify the current POs, which is the progress. For example, after half a week, the progress is 50%.

 

Usage example

/////// Cmfc_ctrl_dlg.h //////////////

Cprogressctrl m_pro;

Afx_msg void ontimer (uint_ptr nidevent );

 

/// // Cmfc_ctrl_dlg.cpp //////////////////////

 

# Define time_id 88

 

//..........

Ddx_control (PDX, idc_pro, m_pro );

//...............

On_wm_timer ()

 

 

Bool cmfc_ctrl_dlg: oninitdialog ()

{

Cdialog: oninitdialog ();

 

Settimer (time_id,); // set the timer to run once every second

M_pro.setrange (0,250 );

M_pro.setpos (0); // set the initial position

}

 

 

Void cmfc_ctrl_dlg: ontimer (uint_ptr nidevent)

{

If (nidevent = time_id)

{

Pos + = 10;

If (Pos> 250)

Pos = 250;

M_pro.setpos (POS); // specifies the current progress

}

}

 

Slider Control

In fact, Slider ctrono is similar to progress control. progress is the progress that the program tells the user what to do, and slider allows the user to specify the progress. the most typical one is that we pull a progress bar when playing a video. it is a slider control.

 

Usage example.

Csliderctrl m_slider;

Ddx_control (PDX, idc_slider1, m_slider );

 

// Initialization

M_slider.setrange (0, 59 );// If the user is asked to select a minute, it can only be a number from 0 to 59

M_slider.setpos (0 );

 

Message Processing. process the message when pulling the progress bar.

On_notify (nm_customdraw, Idc_slider1, & cmfc_ctrl_dlg: onnmcustomdrawslider1)

 

 

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

{

Int nminute = m_slider.getpos ();// Obtain the selected location.

// You can perform other operations based on this information. For example, if the video is used, load the corresponding content according to this number.

}

 

 

 

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.