Share via


CTaskDialog::CTaskDialog

Creates an instance of the CTaskDialog Class.

CTaskDialog(
   const CString& strContent,
   const CString& strMainInstruction,
   const CString& strTitle,
   int nCommonButtons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON,
   int nTaskDialogOptions = TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS,
   const CString& strFooter = _T("")
);

CTaskDialog(
   const CString& strContent,
   const CString& strMainInstruction,
   const CString& strTitle,
   int nIDCommandControlsFirst,
   int nIDCommandControlsLast,
   int nCommonButtons,
   int nTaskDialogOptions = TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS,
   const CString& strFooter = _T("")
);

Parameters

  • [in] strContent
    The string to use for the content of the CTaskDialog.

  • [in] strMainInstruction
    The main instruction of the CTaskDialog.

  • [in] strTitle
    The title of the CTaskDialog.

  • [in] nCommonButtons
    A mask of the common buttons to add to the CTaskDialog.

  • [in] nTaskDialogOptions
    The set of options to use for the CTaskDialog.

  • [in] strFooter
    The string to use as the footer.

  • [in] nIDCommandControlsFirst
    The string ID of the first command.

  • [in] nIDCommandControlsLast
    The string ID of the last command.

Remarks

There are two ways that you can add a CTaskDialog to your application. The first way is to use one of the constructors to create a CTaskDialog and display it using CTaskDialog::DoModal. The second way is to use the static function CTaskDialog::ShowDialog, which enables you to display a CTaskDialog without explicitly creating a CTaskDialog object.

The second constructor creates command button controls by using data from the resource file of your application. The string table in the resource file has several strings with associated string IDs. This method adds a command button control for each valid entry in the string table between nIDCommandControlsFirst and nCommandControlsLast, inclusive. For these command button controls, the string in the string table is the control's caption and the string ID is the control's ID.

See CTaskDialog::SetOptions for a list of valid options.

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

Tasks

Walkthrough: Adding a CTaskDialog to an Application

Reference

CTaskDialog Class

Hierarchy Chart

CTaskDialog::ShowDialog

CTaskDialog::DoModal

CTaskDialog::SetOptions