Objective Toolkit : Chapter 4 Simple Controls : Extended Progress Control
Extended Progress Control
Derived from MFC's CProgressCtrl, SECProgressCtrl offers several enhancements to the existing progress control, including
Smooth fill with percentages.
Multidirectional progressions (left to right, right to left, bottom to top, or top to bottom).
Fully configurable foreground and background coloring.
Custom status text with configurable fonts.
The progress control also offers powerful virtual hooks for you to provide your own customizations easily.
In addition, SECProgressCtrl supports the automatic advancing of the progress status in response to timer events. Refer to StepOnTimer() in the Objective Toolkit Class Reference for more information.
Figure 37 – Example Progress Control
The class hierarchy for the progress control is as follows:
Figure 38 – Objective Toolkit SECProgressCtrl Class Hierarchy
Using SECProgressCtrl
You can use objects instantiated from SECProgressCtrl anywhere you can use CProgressCtrl. You can attach an SECProgressCtrl object to an existing CProgressCtrl control via the AttachProgress() method or you can create the control dynamically via the Create() method.
To attach an SECProgressCtrl instance to an progress control resource:
Call the AttachProgress() method with the control ID of the progress control you want to attach.
 
m_wndProgress.AttachProgress(IDC_PROGRESS,this);
To create an SECProgressCtrl instance dynamically:
1. Create a unique control ID for the control. In Visual Studio, you can create a control ID in the Resource Includes dialog.
2. Call the Create() method.
 
CRect rect(0,0,100,50); // initial rectangle
m_wndProgress.Create(WS_CHILD|WS_VISIBLE,rect, this,IDC_PROGRESS1);
Customizing SECProgressCtrl
You can use the following extended styles to customize the progress control.
Table 22 – Extended Styles for SECProgressCtrl 
Extended style flag
Description
SEC_EX_PROGRESS_VERT
Bar progresses vertically
SEC_EX_PROGRESS_RIGHT_TO_LEFT
If horizontal, bar progresses right to left
SEC_EX_PROGRESS_TOP_TO_BOTTOM
If vertical, bar progresses top to bottom
SEC_EX_PROGRESS_SHOWPERCENT
Show text percentages on bar
SEC_EX_PROGRESS_SHOWTEXT
Show text on bar
SEC_EX_PROGRESS_TEXT_ALIGN_LEFT
If text shown, align text left
SEC_EX_PROGRESS_TEXT_ALIGN_RIGHT
If text shown, align text right
SEC_EX_PROGRESS_TEXT_ALIGN_CENTER
If text shown, center the text
SEC_EX_PROGRESS_ COMMCTRL32
Has look and feel of CProgressCtrl
SEC_EX_PROGRESS_DEFAULTS
SEC_EX_PROGRESS_SHOWPERCENT |SEC_EX_PROGRESS_TEXT_ALIGN_CENTER
 
You can specify these styles as parameters to the Create() and SetExStyle() methods. By default, the progress bar is horizontal and progresses left to right with centered percentages. You can use the preceding flags to modify the default behavior. In addition, the application can configure the font, foreground, and background color at run time.
Extending SECProgressCtrl
Almost every method in SECProgressCtrl is virtual so you can override them. Some of the virtual callbacks provided by this class include:
Table 23 – Virtual Callbacks in SECProgressCtrl 
Method
Description
OnDisplayStr()
Override to alter a progress string before display.
OnPaintBarFill()
Paint the filled portion of the progress bar.
OnPaintBarEmpty()
Paint the empty portion of the progress bar.
OnPaintBarText()
Paint the progress text, if any.