MFC progress bar CProgressCtrl

Source: Internet
Author: User

Introduction of member functions
1. Create ()
This function is required to create a progress bar that is not generated by dragging a progress bar control on a resource file.

2, SetRange ()
Sets the start and end values of the progress bar.

3, SetPos ()
Sets the current position of the progress bar.

4, OffsetPos ()
Move the progress bar some distance

5, SetStep ()
Set Step size

6, StepIt ()
Update location by step

Ii. examples
Example 1: Manually adding a control to the resource window Idc_progress1
CProgressCtrl *MYPROCTRL2 = (CProgressCtrl *) GetDlgItem (IDC_PROGRESS1);
Myproctrl2->setrange (0,100);
for (int i = 0;i<100;i++)
{
Myproctrl2->offsetpos (1); This code is equivalent to the next two sentences, the Fixed step 1 update display, the function can also be implemented as follows: Myproctrl2->setpos (i);
Myproctrl2->setstep (1);
Myproctrl2->stepit ();
Sleep (100);
}

Example 2: The resource window does not increase and the progress bar is generated directly from the code
CProgressCtrl Myproctrl;
CRect Rect,prorect;
GetClientRect (&rect);
prorect.left = rect.left + rect. Width ()/2-100;
prorect.top = rect.top + rect. Height ()/2-20;
prorect.right = Rect.right-rect. Width ()/2 +;
Prorect.bottom = Rect.bottom-rect. Height ()/2 +;
//ws_child| ws_visible| Pbs_smoothreverse
myproctrl.create (ws_visible,prorect,this,99);//create location, size
Myproctrl.setrange (0,100);
int i;
For (i = 0; i <; i++)
{
Myproctrl.offsetpos (1);
CString str;
Str. Format (_t ("%d%%"), i); Percentage
(GetDlgItem (IDC_STATIC1))->setwindowtext (str);
Sleep (+);
}

Better quality and more exciting articles see: http://blog.csdn.net/visualeleven/article/details/6165007

MFC progress bar CProgressCtrl

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.