//创建并初始化CTaskDialog
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 command control
taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");
// 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();
//CTaskDialog仅支持Vista之后的系统,并且只支持Unicode应用
if(CTaskDialog::IsSupported())
{
// 使用任务对话框
}
else
{
MessageBox();
}CTaskDialog的使用
最新推荐文章于 2021-11-03 15:10:50 发布
本文详细介绍了如何使用CTaskDialog组件来创建自定义的任务对话框。包括设置对话框标题、内容、图标等属性,以及如何添加命令按钮和扩展信息。此外,还提供了关于如何调整对话框选项以默认展开额外信息的方法。
1921

被折叠的 条评论
为什么被折叠?



