CTaskDialog::CTaskDialog

建立 CTaskDialog 類別 的執行個體。

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

參數

  • [in] strContent
    使用指定的 URI CTaskDialog的內容。

  • [in] strMainInstruction
    CTaskDialog主要的指示。

  • [in] strTitle
    CTaskDialog 的標題。

  • [in] nCommonButtons
    標記為的按鈕加入至 CTaskDialog遮罩。

  • [in] nTaskDialogOptions
    使用的選項。 CTaskDialog

  • [in] strFooter
    使用字串做為的頁尾。

  • [in] nIDCommandControlsFirst
    第一個命令 ID 的字串。

  • [in] nIDCommandControlsLast
    最後一個命令 ID 的字串。

備註

有兩種方式可以將 CTaskDialog 加入您的應用程式。使用 CTaskDialog::DoModal,第一種方式是使用其中一個建構函式會建立 CTaskDialog 並加以顯示。第二種方式是使用靜態函式 CTaskDialog::ShowDialog,可讓您顯示 CTaskDialog ,而不需明確建立 CTaskDialog 物件。

第二個建構函式會建立命令按鈕控制項會使用資料從應用程式資源檔中。在資源檔中的字串資料表有關聯的字串 ID 的多個字串。這個方法會將每一個有效輸入的命令按鈕控制項在 nIDCommandControlsFirst 和 nCommandControlsLast的字串資料表中,包含。如需這些命令按鈕控制項,字串資料表是控制項的標題,以及字串 ID 是控制項的 ID.

如需有效選項清單中看到 CTaskDialog::SetOptions

範例

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

需求

標題: afxtaskdialog.h

請參閱

工作

逐步解說: 在應用程式中加入 CTaskDialog

參考

CTaskDialog 類別

階層架構圖

CTaskDialog::ShowDialog

CTaskDialog::DoModal

CTaskDialog::SetOptions