MFC progress bar

I. INTRODUCTION member function 
1, create ()
for generating not drag the progress bar control by the progress bar on the resource file, you need to create a function with this.

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

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

4, OffSetPos ()
moves the progress bar at a distance

5, SetStep ()
setting step

6, StepIt ()
in steps of updating the location

Second, Examples
Example 1: Increase in the manual resource window control IDC_PROGRESS1
CProgressCtrl * myProCtrl2 = (CProgressCtrl *) the GetDlgItem (IDC_PROGRESS1);
myProCtrl2-> the SetRange (0,100);
for (int I = 0; I <100; I ++)
{
/ / myProCtrl2-> OffsetPos (1); // sentence equivalent to the two codes, to a fixed step to update the display, this function can also be achieved: myProCtrl2-> SetPos (I); 
myProCtrl2-> SETSTEP (1) ;
myProCtrl2-> StepIt ();
Sleep (100);
}

Example 2: Resource window is not increasing, directly by the code generation progress bar
CProgressCtrl myProCtrl;
CRect RECT, proRect;
the GetClientRect (& RECT);
proRect.left = rect.left rect.width + () / 2 - 100;
proRect.top = RECT + rect.height .top () / 2 - 20 is;
proRect.right = rect.right - rect.width () / 2 + 100;
proRect.bottom = rect.bottom - rect.height () / 2 + 20 is;
/ / the WS_CHILD | the WS_VISIBLE | PBS_SMOOTHREVERSE 
myProCtrl.Create (the WS_VISIBLE, proRect, the this, 99); // create a location, size
myProCtrl.SetRange (0,100);
int I;
for (I = 0; I <100; I ++)
{
myProCtrl. OffsetPos (. 1);
CString STR;
str.format (_T ( "% D %%"), I); // percentage
(the GetDlgItem (IDC_STATIC1)) -> the SetWindowText (STR);
Sleep (100);
}

Article Source https://www.cnblogs.com/huhu0013/p/4434031.html

Guess you like

Origin www.cnblogs.com/nxopen2018/p/11131670.html