CTaskDialog的使用

本文详细介绍了如何使用CTaskDialog组件来创建自定义的任务对话框。包括设置对话框标题、内容、图标等属性,以及如何添加命令按钮和扩展信息。此外,还提供了关于如何调整对话框选项以默认展开额外信息的方法。
//创建并初始化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();
}

TaskDialog信息框支持库。 操作系统支持: Windows 注意:TaskDialog信息框的API是在Vista之后才被加入的,所以,在Vista以下电脑慎用!! 前言 本程序基于CTaskDialog类,前阵子发布过一个不是很完善的程序。本次开放了:“TaskDialogCallbackProc”接口,可以对TaskDialog进行消息处理。 增加内容 增加的常量: 通知消息 wParam 值 lParam 值 TDN_CREATED 未使用。 未使用。 TDN_NAVIGATED 未使用。 未使用。 TDN_BUTTON_CLICKED 命令按钮控件ID. 未使用。 TDN_HYPERLINK_CLICKED 命令按钮控件ID. 包含指向的 LPCWSTR 结构。 TDN_TIMER 重置毫秒,因为 CTaskDialog 创建或计时器的时间。 未使用。 TDN_DESTROYED 未使用。 未使用。 TDN_RADIO_BUTTON_CLICKED 单选按钮的ID. 未使用。 TDN_DIALOG_CONSTRUCTED 未使用. 未使用。 TDN_VERIFICATION_CLICKED 1,复选框处于选中状态,0;未启用。 未使用。 TDN_HELP 未使用。 未使用。 TDN_EXPANDO_BUTTON_CLICKED 0,展开区域处于折叠状态;非零,外接文本显示。 未使用。 功能常量名 作用 S_OK 对于TaskDialogCallbackProc处理完成后返回,并把执行权交回TaskDialog S_FALSE 对于TaskDialogCallbackProc处理完成后,不把执行权交回TaskDialog 备注 TaskDialogCallback 处理的默认实现特定消息然后调用适当在 CTaskDialog类选件的方法。 例如,在响应 TDN_BUTTON_CLICKED 消息,TaskDialogCallback 调用 CTaskDialog::OnCommandControlClick。 wParam 和 lParam 的值取决于特定生成的消息。 可以为或这两个值可以为空。 下表列出了支持的默认值通知,以及 wParam 和 lParam 的值表示。 如果您具有派生类中重写此方法,则应实现每个消息的回调代码在下表中。 效果 解释: TaskDialog中设置了回调事件“TaskDialogCallbackProc2”,然后取出进度条句柄,修改进度条的进度。 更多例子: 链接测试 月历测试
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值