成员函数
BOOL GoModal(LPCTSTR strTitle = _T("Progress"), BOOL bSmooth=FALSE); // Make window modal
int SetPos(int nPos); // Same as CProgressCtrl
int OffsetPos(int nPos); // Same as CProgressCtrl
int SetStep(int nStep); // Same as CProgressCtrl
int StepIt(); // Same as CProgressCtrl
void SetRange(int nLower, int nUpper, int nStep = 1);
// Set min, max and step size
void Hide(); // Hide the window
void Show(); // Show the window
void Clear(); // Clear the text and reset the progress bar
void SetText(LPCTSTR fmt, ...); // Set the text in the text area
BOOL Cancelled() // Has the cancel button been pressed?
void SetWindowSize(int nNumTextLines, int nWindowWidth = 390);
// Sets the size of the window according to
// the number of text lines specifed and the
// desired window size in pixels.
void PeekAndPump(BOOL bCancelOnESCkey = TRUE);
// Message pumping, with options of allowing
// Cancel on ESC key.
使用该类方法可以如下:
CProgressWnd wndProgress(this, "Progress");
// wndProgress.GoModal(); // Call this if you want a modal window
wndProgress.SetRange(0,5000);
wndProgress.SetText("Processing...");
for (int i = 0; i <5000; i++) { wndProgress.StepIt(); wndProgress.PeekAndPump(); if (wndProgress.Cancelled()) { MessageBox("Progress Cancelled"); break; } }
或者是下面的两步创建法:
CProgressWnd wndProgress;
if (!wndProgress.Create(this, "Progress"))
return;
wndProgress.SetRange(0,5000);
wndProgress.SetText("Processing...");