CTaskDialog::SetOptions
配置 CTaskDialog的选项。
void SetOptions(
int nOptionFlag
);
参数
- [in] nOptionFlag
设置标志。CTaskDialog使用。
备注
此方法清除 CTaskDialog的所有当前选项卡。 若要保留当前选项,必须先检索它们与 CTaskDialog::GetOptions 并将它们与要设置的选项。
下表列出所有活动的选项。
TDF_ENABLE_HYPERLINKS
可以在 CTaskDialog的超链接。TDF_USE_HICON_MAIN
配置 CTaskDialog 为主图标使用 HICON。 种方法是使用 LPCWSTR。TDF_USE_HICON_FOOTER
配置 CTaskDialog 为页脚图标使用 HICON。 种方法是使用 LPCWSTR。TDF_ALLOW_DIALOG_CANCELLATION
允许用户关闭 CTaskDialog 使用键盘或使用图标在对话框的右上角,因此,即使 取消 按钮未启用。 此标记不设置,并 取消 按钮未启用,使用Alt+F4,用户无法关闭对话框,转义键或标题栏的"关闭"按钮。TDF_USE_COMMAND_LINKS
配置 CTaskDialog 使用命令按钮控件。TDF_USE_COMMAND_LINKS_NO_ICON
配置 CTaskDialog 使用命令按钮控件,而不显示图标位于控件旁边。 TDF_USE_COMMAND_LINKS 重写 TDF_USE_COMMAND_LINKS_NO_ICON。TDF_EXPAND_FOOTER_AREA
指示展开当前区域展开。TDF_EXPANDED_BY_DEFAULT
确定展开区域默认情况下是否展开。TDF_VERIFICATION_FLAG_CHECKED
指示验证复选框当前选定。TDF_SHOW_PROGRESS_BAR
配置 CTaskDialog 显示一个进度栏。TDF_SHOW_MARQUEE_PROGRESS_BAR
配置进度栏是一个marquee进度栏。 如果启用此选项,则必须设置 TDF_SHOW_PROGRESS_BAR 具有所需的行为。TDF_CALLBACK_TIMER
指示 CTaskDialog 回调间隔设置为大约为200毫秒。TDF_POSITION_RELATIVE_TO_WINDOW
配置 CTaskDialog 中居中相对于父窗口。 此标记不活动,CTaskDialog 中居中相对于个监视器。TDF_RTL_LAYOUT
配置一个从右向左的读取格式的 CTaskDialog。TDF_NO_DEFAULT_RADIO_BUTTON
指示单选按钮未被选定,当 CTaskDialog 显示。TDF_CAN_BE_MINIMIZED
使用户最小化 CTaskDialog。 若要支持此选项,CTaskDialog 不能是模式化的。 因为MFC不支持无模式 CTaskDialog,MFC不支持此选项。
示例
// 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