1. Select Resource Symbols from the View menu to add a new ID (assuming in this case
ID_Indicator_Progress_pane), allowing your computer to assign a value for the ID.
2. Look for an Indicators array in Mainfrm.cpp, then add the added ID above this array.
Please place it behind other IDs, which will make the future progress bar appear on the right side of the status line, if you
Do not want the progress bar to appear on the far right, you can also place the ID in other places you want to appear.
3. Open the string table in the resource file and insert a new string. You can pass the INSERT menu
To join a new character table, or click the right button on the string table or you can do this.
4. The character of the string is a new id, then add the appropriate space. (Added space
At least the progress of the established schedule is larger)
Now we have established an empty rectangle, followed by putting a progress bar here.
1. Declare a public variable in Mainfrm.h, type CProgressCtrl (assuming m_progress)
2. Declare a protective variable in Mainfrm.h, type BOOL (assuming m_bcreated)
3. In the oncreate () function of the mainfrm.cpp, M_BCREATED is initialized to False:
m_bcreated = false;
4. Now when we need to use the progress bar, let's check if it has been established, if not yet,
Then we need to build:
CMAINFRAME :: OnsomelongProcess ()
{
Rect myRECT;
// Substitution 4 with the zero-based index of Your Status bar Pane.
// for example, if you put your Pane first in the indeicators array,
// YOU PUT 0, SECOND you 抎 Put 1, ETC.
M_WndStatusBar.getItemRect (4, & myRect);
IF (m_bcreated == false)
{
// Create The Progress Control
M_Progress.create (WS_Visible | WS_CHILD, MyRect, & WndStatusbar, 1);
M_Progress.SetRange (0,100); // set the Range to BetWeen 0 and 100
M_Progress.setstep (1); // set the step Amount
m_bcreated = true;
}
// NOW WE 抣 L Simulate a long process:
For (int i = 0; i <100; i ) {Sleep (20); m_progress.stepit ();}}
If the window is established after the progress bar is established, the progress bar will not be re-adjusted position.
Taking our code we must add your own code in the WM_SIZE event to adjust the progress bar:
Void CMAINFRAME :: Onsize (uint ntype, int CX, int CY)
{
CmdiframeWnd :: OnSize (NTYPE, CX, CY);
Rect RC;
m_wndstatusbar.getitemRect (4, & RC);
// Reposition The Progress Control Correctly!
M_Progress.SetWindowPOS (& Wndtop, Rc.Left, rc.top, rc.right - rc.left,
Rc.bottom - rc.top, 0);
}
This is the method of implementing progress bar in the status line, although it looks long, but in fact it is very simple.