Sdílet prostřednictvím


CTaskDialog::SetOptions

Configures the options for the CTaskDialog.

void SetOptions(
   int nOptionFlag
);

Parameters

  • [in] nOptionFlag
    The set of flags to use for the CTaskDialog.

Remarks

This method clears all the current options for the CTaskDialog. To preserve the current options, you must retrieve them first with CTaskDialog::GetOptions and combine them with the options that you want to set.

The following table lists all the valid options.

  • TDF_ENABLE_HYPERLINKS
    Enables hyperlinks in the CTaskDialog.

  • TDF_USE_HICON_MAIN
    Configures the CTaskDialog to use a HICON for the main icon. The alternative is to use a LPCWSTR.

  • TDF_USE_HICON_FOOTER
    Configures the CTaskDialog to use a HICON for the footer icon. The alternative is to use a LPCWSTR.

  • TDF_ALLOW_DIALOG_CANCELLATION
    Enables the user to close the CTaskDialog by using the keyboard or by using the icon in the upper-right corner of the dialog box, even if the Cancel button is not enabled. If this flag is not set and the Cancel button is not enabled, the user cannot close the dialog box by using Alt+F4, the Escape key, or the title bar's close button.

  • TDF_USE_COMMAND_LINKS
    Configures the CTaskDialog to use command button controls.

  • TDF_USE_COMMAND_LINKS_NO_ICON
    Configures the CTaskDialog to use command button controls without displaying an icon next to the control. TDF_USE_COMMAND_LINKS overrides TDF_USE_COMMAND_LINKS_NO_ICON.

  • TDF_EXPAND_FOOTER_AREA
    Indicates the expansion area is currently expanded.

  • TDF_EXPANDED_BY_DEFAULT
    Determines whether the expansion area is expanded by default.

  • TDF_VERIFICATION_FLAG_CHECKED
    Indicates the verification check box is currently selected.

  • TDF_SHOW_PROGRESS_BAR
    Configures the CTaskDialog to display a progress bar.

  • TDF_SHOW_MARQUEE_PROGRESS_BAR
    Configures the progress bar to be a marquee progress bar. If you enable this option, you must set TDF_SHOW_PROGRESS_BAR to have the expected behavior.

  • TDF_CALLBACK_TIMER
    Indicates that the CTaskDialog callback interval is set to approximately 200 milliseconds.

  • TDF_POSITION_RELATIVE_TO_WINDOW
    Configures the CTaskDialog to be centered relative to the parent window. If this flag is not enabled, the CTaskDialog is centered relative to the monitor.

  • TDF_RTL_LAYOUT
    Configures the CTaskDialog for a right-to-left reading layout.

  • TDF_NO_DEFAULT_RADIO_BUTTON
    Indicates that no radio button is selected when the CTaskDialog appears.

  • TDF_CAN_BE_MINIMIZED
    Enables the user to minimize the CTaskDialog. To support this option, the CTaskDialog cannot be modal. MFC does not support this option because MFC does not support a modeless CTaskDialog.

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 );

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
    L"Click here for more information.",
    L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

Requirements

Header: afxtaskdialog.h

See Also

Reference

CTaskDialog Class

Hierarchy Chart

CTaskDialog::GetOptions