CTaskDialog::SetProgressBarState
Sets the state of the progress bar and displays it on the CTaskDialog.
void SetProgressBarState(
int nState = PBST_NORMAL
);
Parameters
- [in] nState
The state of the progress bar. See the Remarks section for the possible values.
Remarks
This method throws an exception with the ENSURE (MFC) macro if the CTaskDialog is already displayed and has a marquee progress bar.
The following table lists the possible values for nState. In all these cases, the progress bar will fill with the regular color until it reaches the designated stop position. At that point it will change color based on the state.
PBST_NORMAL
After the progress bar fills, the CTaskDialog does not change the color of the bar. By default, the regular color is green.PBST_ERROR
After the progress bar fills, the CTaskDialog changes the color of the bar to the error color. By default, this is red.PBST_PAUSED
After the progress bar fills, the CTaskDialog changes the color of the bar to the paused color. By default, this is yellow.
You can set where the progress bar stops with CTaskDialog::SetProgressBarPosition.
Example
// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");
CTaskDialog taskDialog(message, mainInstruction, title,
TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON );
// Add a marquee progress bar.
taskDialog.SetProgressBarMarquee();
taskDialog.DoModal();
// Remove the marquee bar and replace it with a standard progress bar
taskDialog.SetProgressBarMarquee(0);
taskDialog.SetProgressBarRange(0, 100);
taskDialog.SetProgressBarPosition(75);
taskDialog.SetProgressBarState();
taskDialog.DoModal();
Requirements
Header: afxtaskdialog.h
See Also
Reference
CTaskDialog::SetProgressBarMarquee