/** * @file XTPTaskDialog.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPTASKDIALOG_H__) # define __XTPTASKDIALOG_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPPropExchangeXMLNode; /** * @brief * The CXTPTaskDialog class creates, displays, and operates a task * dialog. A task dialog is similar to, while much more flexible than, * a basic message box. The task dialog contains application-defined * messages, title, verification check box, command links and push * buttons, plus any combination of predefined icons and push buttons. */ class _XTP_EXT_CLASS CXTPTaskDialog : public CXTPTaskDialogFrame { public: /** * @brief * Constructs a CXTPTaskDialog object. * @param pWndParent Pointer to the parent or owner window object. */ CXTPTaskDialog(CWnd* pWndParent = NULL); /** * @brief * Destroys a CXTPTaskDialog object, handles cleanup and deallocation. */ virtual ~CXTPTaskDialog(); /** * @brief * Call this member function to set the window title for the task dialog. * @param pszText Pointer that references the string to be used for the * task dialog title. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. If this parameter is NULL, then the filename of the executable * program is used. * @see * SetWidth, EnableCancellation, EnableRelativePosition, * EnableRtlLayout, EnableMinimize, OnDialogConstructed */ void SetWindowTitle(LPCTSTR pszText); /** * @brief * Call this member function to set the label for the verification * checkbox to be displayed in the task dialog. * @param pszText Pointer that references the string to be used to label * the verification checkbox. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. If this parameter is NULL, then the verification checkbox is not * displayed in the task dialog. * @see * OnVerificationClicked, SetVerifyCheckState, IsVerificiationChecked, * ClickVerification */ void SetVerificationText(LPCTSTR pszText); /** * @brief * Call this member function to set the expanded control text for the * task dialog. This function is ignored unless SetExpandedInformation * has been called. * @param pszText Pointer that references the string to be used to label * the button for collapsing the expandable information. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. If this parameter is NULL, then the value set with * SetCollapsedControlText will be used for the expanded control text * as well. * @see * SetCollapsedControlText, SetExpandedInformation, ExpandedByDefault, * ExpandFooterArea, OnExpandoButtonClicked */ void SetExpandedControlText(LPCTSTR pszText); /** * @brief * Call this member function to set the collapsed control text for the * task dialog. This function is ignored unless SetExpandedInformation * has been called. * @param pszText Pointer that references the string to be used to label * the button for expanding the expandable information. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. If this parameter is NULL, then the value set with * SetExpandedControlText will be used for the collapsed control text * as well. * @see * SetExpandedControlText, SetExpandedInformation, ExpandedByDefault, * ExpandFooterArea, OnExpandoButtonClicked */ void SetCollapsedControlText(LPCTSTR pszText); /** * @brief * Call this member function to set the main instruction text for the * task dialog. * @param pszText Pointer that references the string to be used for the main * instruction. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE macro. * @return * TRUE if successful, otherwise FALSE. */ BOOL SetMainInstruction(LPCTSTR pszText); /** * @brief * Call this member function to set the content text for the task dialog. * @param pszText Pointer that references the string to be used for the * dialog's primary content. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. If EnableHyperlinks has been called, then this string may * contain hyperlinks in the form: *
* \Hyperlink Text\. ** @return * TRUE if successful, otherwise FALSE. * @see * OnHyperlinkClicked, SetExpandedInformation, SetFooter, EnableHyperlinks */ BOOL SetContent(LPCTSTR pszText); /** * @brief * Call this member function to set the expanded information text for * the task dialog. * @param pszText Pointer that references the string to be used for displaying * additional information. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. The additional information is displayed either immediately * below the content or below the footer text depending on whether * ExpandFooterArea has been calle d. If EnableHyperlinks has been called, * then this string may contain hyperlinks in the form: *
* \Hyperlink Text\. ** @return * TRUE if successful, otherwise FALSE. * @see * SetCollapsedControlText, SetExpandedControlText, ExpandedByDefault, * ExpandFooterArea, OnExpandoButtonClicked, * SetContent, OnHyperlinkClicked, SetFooter, EnableHyperlinks */ BOOL SetExpandedInformation(LPCTSTR pszText); /** * @brief * Call this member function to set the footer text for the task dialog. * @param pszText Pointer that references the string to be used in the footer * area of the task dialog. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. If EnableHyperlinks has been called, then this string may * contain hyperlinks in the form: *
* \Hyperlink Text\. ** @return * TRUE if successful, otherwise FALSE. * @see * SetContent, SetExpandedInformation, OnHyperlinkClicked, EnableHyperlinks */ BOOL SetFooter(LPCTSTR pszText); /** * @brief * Call this member function to set the icon for the Main Instruction * area of the task dialog. * @param hIcon A handle to an Icon that is to be displayed in the task * dialog Main Instruction area. If this member is NULL, * then no icon will be displayed. * @details * The parameter pszResource must be an integer resource * identifier passed to the MAKEINTRESOURCE macro, or one of the * following predefined values: * * TD_ERROR_ICON: A stop-sign icon appears in the task * dialog. * TD_WARNING_ICON: An exclamation-point icon appears in * the task dialog. * TD_INFORMATION_ICON: An icon consisting of a lowercase * letter i in a circle appears * in the task dialog. * TD_SHIELD_ICON: A shield icon appears in the task * dialog. * @return * TRUE if successful, otherwise FALSE. */ BOOL SetMainIcon(HICON hIcon); /** * @brief * Call this member function to set the icon for the Main Instruction * area of the task dialog. * @param pszResource Pointer that references the icon to be displayed in * the task dialog footer area. If this parameter is * NULL, then no icon will be displayed. * @details * The parameter pszResource must be an integer resource * identifier passed to the MAKEINTRESOURCE macro, or one of the * following predefined values: * * TD_ERROR_ICON: A stop-sign icon appears in the task * dialog. * TD_WARNING_ICON: An exclamation-point icon appears in * the task dialog. * TD_INFORMATION_ICON: An icon consisting of a lowercase * letter i in a circle appears * in the task dialog. * TD_SHIELD_ICON: A shield icon appears in the task * dialog. * @return * TRUE if successful, otherwise FALSE. */ BOOL SetMainIcon(LPCWSTR pszResource); /** * @brief * Call this member function to use system icons * @param bUseSysIcons TRUE to use system icons when available for TD_ERROR_ICON, * TD_WARNING_ICON, TD_INFORMATION_ICON and TD_SHIELD_ICON * instead of Codejock Software icons. This parameter is * ignored when bUseComCtl32 is set to TRUE. */ void SetUseSysIcons(BOOL bUseSysIcons = TRUE); /** * @brief * Call this member function to use ComCtl32.dll in Vista to show TaskDialog. * @param bUseComCtl32 TRUE to use ComCtl32.dll in Vista to show TaskDialog. */ void SetUseComCtl32(BOOL bUseComCtl32 = TRUE); /** * @brief * Call this member function to set the icon for the Footer area of the * task dialog. * @param hIcon A handle to an Icon that is to be displayed in the task * dialog footer area. If this member is NULL, then * no icon will be displayed. * @details * The parameter pszResource must be an integer resource * identifier passed to the MAKEINTRESOURCE macro, or one of the * following predefined values: * * TD_ERROR_ICON: A stop-sign icon appears in the task * dialog. * TD_WARNING_ICON: An exclamation-point icon appears in * the task dialog. * TD_INFORMATION_ICON: An icon consisting of a lowercase * letter i in a circle appears * in the task dialog. * TD_SHIELD_ICON: A shield icon appears in the task * dialog. * @return * TRUE if successful, otherwise FALSE. */ BOOL SetFooterIcon(HICON hIcon); /** * @brief * Call this member function to set the icon for the Footer area of the * task dialog. * @param pszResource Pointer that references the icon to be displayed in * the task dialog footer area. If this parameter * is NULL, then no icon will be displayed. * @details * The parameter pszResource must be an integer resource * identifier passed to the MAKEINTRESOURCE macro, or one of the * following predefined values: * * TD_ERROR_ICON: A stop-sign icon appears in the task * dialog. * TD_WARNING_ICON: An exclamation-point icon appears in * the task dialog. * TD_INFORMATION_ICON: An icon consisting of a lowercase * letter i in a circle appears * in the task dialog. * TD_SHIELD_ICON: A shield icon appears in the task * dialog. * @return * TRUE if successful, otherwise FALSE. */ BOOL SetFooterIcon(LPCWSTR pszResource); /** * @brief * Call this member function to set the width of the task dialog's * client area. * @param cxWidth Specifies the width of the task dialog's client area * in dialog units. If 0, then task dialog will calculate * the ideal width. * @param bPixelToDLU TRUE indicates that the size specified by cxWidth are pixel * units and need to be converted into dialog units (DLU). * @see * SetWindowTitle, EnableCancellation, EnableRelativePosition, * EnableRtlLayout, EnableMinimize, OnDialogConstructed */ void SetWidth(int cxWidth, BOOL bPixelToDLU = FALSE); /** * @brief * Call this member function to add a user-defined button to the * task dialog's command area. * @param pszText Pointer that references the string to be used to label * the button. * @param nButtonID Indicates the value to be returned when this button * is selected. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE * macro. When using Command Links, you delineate the command from * the note by placing a new line character in the string. * @see * OnButtonClicked, EnableCommandLinks, SetDefaultButton, SetCommonButtons, * GetSelectedButtonId, ClickButton, EnableButton, SetButtonElevationRequired */ void AddButton(LPCTSTR pszText, int nButtonID); /** * @brief * Call this member function to add a user-defined radio button to the * task dialog's command area. * @param pszText Pointer that references the string to be used to label * the radio button. * @param nButtonID Indicates the value to be returned when this button * is selected. * @details * The parameter pszText can be either a NULL-terminated string * or an integer resource identifier passed to the MAKEINTRESOURCE macro. * @see * OnRadioButtonClicked, SetDefaultRadioButton, NoDefaultRadioButton, * GetSelectedRadioButtonId, ClickRadioButton, EnableRadioButton */ void AddRadioButton(LPCTSTR pszText, int nButtonID); /** * @brief * Call this member function to add a user input box to the * task dialog's command area. * @details * Call SetInputBoxText to set the default value for an input box field. * @see * SetInputBoxText, GetInputBoxText */ void AddInputBox(); /** * @brief * Call this member function to set the default value for an * input box field. * @param lpszInputBoxText Text to display in the input box. * @details * Call AddInputBox to add a user input box to the task dialog's command area. * @see * AddInputBox, GetInputBoxText */ void SetInputBoxText(LPCTSTR lpszInputBoxText); /** * @brief * Call this member function to get the text entered by a user in * an input box field. * @details * Call AddInputBox to add a user input box to the task dialog's command area. * @return Returns the text entered by a user in an input box field * @see * AddInputBox, SetInputBoxText */ CString GetInputBoxText() const; /** * @brief * Call this member function to indicate that the buttons specified with * AddButton should be displayed as command links (using a standard * task dialog glyph) instead of push buttons. This function is ignored * if AddButton has not been called. * @param bEnable TRUE to enable command links, FALSE to disable. * @param bShowIcon TRUE if the command links should display a glyph. * @details * When using command links, all characters up to the first new line * character in AddButton's pszText argument will be treated as the * command link's main text, and the remainder will be treated as the * command link's note. * @see * AddButton, OnButtonClicked, SetDefaultButton, SetCommonButtons, * GetSelectedButtonId, ClickButton, EnableButton, SetButtonElevationRequired */ void EnableCommandLinks(BOOL bEnable = TRUE, BOOL bShowIcon = TRUE); /** * @brief * Enables hyperlink processing for the strings specified for the * functions SetContent, SetExpandedInformation, and SetFooter. * @param bEnable TRUE to enable hyperlinks, FALSE to disable. * @details * When enabled, Content, Expanded Information, and Footer strings * can contain hyperlinks in the form: *
* \Hyperlink Text\. ** @see * SetContent, SetExpandedInformation, SetFooter, OnHyperlinkClicked */ void EnableHyperlinks(BOOL bEnable = TRUE); /** * @brief * Call this method to enable markup for TaskDialog. * @param bEnable TRUE to enable markup. */ void EnableMarkup(BOOL bEnable = TRUE); /** * @brief * Call this member function to allow dialog cancellation for the * task dialog. * @param bEnable TRUE to allow dialog cancellation, otherwise FALSE. * @details * When bAllow is TRUE, this indicates that the dialog should * be able to be closed using Alt-F4, Escape, and the title bar's * close button even if no cancel button is specified by the * SetCommonButtons or AddButton member functions. * @see * SetWidth, SetWindowTitle, EnableRelativePosition, * EnableRtlLayout, EnableMinimize, OnDialogConstructed */ void EnableCancellation(BOOL bEnable = TRUE); /** * @brief * Call this member function to position the task dialog relative to the * parent window. * @param bEnable TRUE to reposition the task dialog, otherwise FALSE. * @details * When bEnable is TRUE, this indicates that the task dialog * should be positioned (centered) relative to the window specified by * the hWndParent argument in the DoModal member function. If bEnable * is FALSE, or hWndParent is NULL, then the task dialog is positioned * (centered) relative to the monitor. * @see * SetWidth, EnableCancellation, SetWindowTitle, * EnableRtlLayout, EnableMinimize, OnDialogConstructed */ void EnableRelativePosition(BOOL bEnable = TRUE); /** * @brief * Call this member function to display a progress bar for the * task dialog. * @param bShow TRUE indicates that a progress bar should be displayed. * @param bMarquee TRUE indicates the progress bar should be Marquee style. * @see * SetMarqueeProgressBar, SetProgressBarState, SetProgressBarRange, * SetProgressBarPos, StartProgressBarMarquee */ void ShowProgressBar(BOOL bShow, BOOL bMarquee = FALSE); /** * @brief * Call this member function to enable right-to-left (RTL) text display * for the task dialog. * @param bEnable TRUE indicates that text should be displayed reading * right-to-left (RTL). * @see * SetWidth, EnableCancellation, EnableRelativePosition, * SetWindowTitle, EnableMinimize, OnDialogConstructed */ void EnableRtlLayout(BOOL bEnable = TRUE); /** * @brief * Call this member function to display the text specified by the * SetExpandedInformation member function when the dialog is initially * displayed. This function is ignored if the SetExpandedInformation * member function has not been called. * @param bExpanded TRUE indicates that the string specified by the * SetExpandedInformation member function should be displayed * when the dialog is initially displayed. * @see * SetCollapsedControlText, SetExpandedInformation, SetExpandedControlText, * ExpandFooterArea, OnExpandoButtonClicked */ void ExpandedByDefault(BOOL bExpanded = TRUE); /** * @brief * Call this member to display expanded information at the bottom of * the task dialog's footer. This function is ignored if the * SetExpandedInformation member function has not been called. * @param bExpandFooter TRUE indicates that the string specified by the * SetExpandedInformation member should be displayed * at the bottom of the dialog's footer area instead * of immediately after the dialog's content. * @see * SetCollapsedControlText, SetExpandedInformation, ExpandedByDefault, * SetExpandedControlText, OnExpandoButtonClicked */ void ExpandFooterArea(BOOL bExpandFooter = TRUE); /** * @brief * Call this member function to set the default button ID for the * task dialog. * @param nButtonID Indicates the default button for the dialog. * @details * nButtonID may be any of the values specified when calling the * AddButton member function, or one of the IDs corresponding to the * buttons specified in the SetCommonButtons member function: * * IDCANCEL: Make the Cancel button the default. * IDNO: Make the No button the default. * IDOK: Make the OK button the default. * IDRETRY: Make the Retry button the default. * IDYES: Make the Yes button the default. * IDCLOSE: Make the Close button the default. * * If this member is zero or its value does not correspond to any button ID * in the dialog, then the first button in the dialog will be the default. * @see * AddButton, EnableCommandLinks, OnButtonClicked, SetCommonButtons, * GetSelectedButtonId, ClickButton, EnableButton, SetButtonElevationRequired */ void SetDefaultButton(int nButtonID); /** * @brief * Call this member function to set the default radio button ID for the * task dialog. * @param nButtonID Indicates the default radio button for the dialog. * @details * nButtonID may be any of the values specified when calling the * AddRadioButton member function. If this member is zero or its value * does not correspond to any radio button ID in the dialog, then the * first button in the dialog will be the default. * @see * AddRadioButton, OnRadioButtonClicked, NoDefaultRadioButton, * GetSelectedRadioButtonId, ClickRadioButton, EnableRadioButton */ void SetDefaultRadioButton(int nButtonID); /** * @brief * Call this member function to disable default radio button selection. * @param bNoDefault TRUE indicates that no default item will be selected. * @see * AddRadioButton, SetDefaultRadioButton, OnRadioButtonClicked, * GetSelectedRadioButtonId, ClickRadioButton, EnableRadioButton */ void NoDefaultRadioButton(BOOL bNoDefault); /** * @brief * Call this member function to set the checked state for the verification * checkbox when the dialog is initially displayed. This function is * ignored if the SetVerificationText member function has not been called. * @param bChecked TRUE indicates that the verification checkbox in the * dialog should be checked when the dialog is initially * displayed. * @see * OnVerificationClicked, OnVerificationClicked, IsVerificiationChecked, * ClickVerification */ void SetVerifyCheckState(BOOL bChecked = TRUE); /** * @brief * Call this member function to enable the callback timer. * @param bEnable TRUE indicates that the task dialog's callback should * be called approximately every 200 milliseconds. * @see * OnTimer, ModifyTaskStyle */ void EnableCallbackTimer(BOOL bEnable = TRUE); /** * @brief * Call this member function to enable the the task dialog to be minimized. * @param bEnable TRUE indicates that the task dialog's title bar and system * menu contain the minimize command. * @see * SetWidth, EnableCancellation, EnableRelativePosition, * EnableRtlLayout, SetWindowTitle, OnDialogConstructed */ void EnableMinimize(BOOL bEnable); /** * @brief * Specifies the push buttons displayed in the task dialog. If no * common buttons are specified and no custom buttons are specified using * the AddButton member function, then the task dialog will contain * the OK button by default. * @param dwButtons Can be any combination of the flags listed in the * remarks section. * @details * Any of the following flags can be used with the dwButtons parameter: * * TDCBF_OK_BUTTON: The task dialog contains the OK push button. * TDCBF_YES_BUTTON: The task dialog contains the Yes push button. * TDCBF_NO_BUTTON: The task dialog contains the No push button. * TDCBF_CANCEL_BUTTON: The task dialog contains the Cancel push button. * TDCBF_RETRY_BUTTON The task dialog contains the Retry push button. * TDCBF_CLOSE_BUTTON: The task dialog contains the Close push button. * * If the Cancel button is specified, then the task dialog will respond to * typical cancel actions (Alt-F4 and Escape). * @see * AddButton, EnableCommandLinks, SetDefaultButton, OnButtonClicked, * GetSelectedButtonId, ClickButton, EnableButton, SetButtonElevationRequired */ void SetCommonButtons(TASKDIALOG_COMMON_BUTTON_FLAGS dwButtons); /** * @brief * Specifies the push buttons displayed in the task dialog. If no * common buttons are specified and no custom buttons are specified using * the AddButton member function, then the task dialog will contain * the OK button by default. * @param bOk TRUE if the task dialog contains the OK push button. * @param bYes TRUE if the task dialog contains the Yes push button. * @param bNo TRUE if the task dialog contains the No push button. * @param bCancel TRUE if the task dialog contains the Cancel push button. * @param bRetry TRUE if the task dialog contains the Retry push button. * @param bClose TRUE if the task dialog contains the Close push button. * @details * Any of the following flags can be used with the dwButtons parameter: * * TDCBF_OK_BUTTON: The task dialog contains the OK push button. * TDCBF_YES_BUTTON: The task dialog contains the Yes push button. * TDCBF_NO_BUTTON: The task dialog contains the No push button. * TDCBF_CANCEL_BUTTON: The task dialog contains the Cancel push button. * TDCBF_RETRY_BUTTON The task dialog contains the Retry push button. * TDCBF_CLOSE_BUTTON: The task dialog contains the Close push button. * * If the Cancel button is specified, then the task dialog will respond to * typical cancel actions (Alt-F4 and Escape). * @see * AddButton, EnableCommandLinks, SetDefaultButton, OnButtonClicked, * GetSelectedButtonId, ClickButton, EnableButton, SetButtonElevationRequired */ void SetCommonButtons(BOOL bOk, BOOL bYes, BOOL bNo, BOOL bCancel, BOOL bRetry, BOOL bClose); /** * @brief * Call this member function to display the task dialog and return * the selected button when done. * @return * The return value is one of the button IDs specified in the AddButton * member function or one of the following values: * * 0: Function call failed. * IDCANCEL: Cancel button was selected, Alt-F4 was pressed, Escape was * pressed, or the user clicked on the close window button. * IDNO: No button was selected. * IDOK: OK button was selected. * IDRETRY: Retry button was selected. * IDYES: Yes button was selected. * Example: *
* CXTPTaskDialog taskDlg(this);
* taskDlg.AddButton(_T(\"Change password"), IDOK);
* taskDlg.SetCommonButtons(TDCBF_CANCEL_BUTTON);
* taskDlg.SetMainIcon(TD_WARNING_ICON);
* taskDlg.SetMainInstruction(_T("Change Password"));
* taskDlg.SetContent(_T("Remember your changed password."));
*
* int nRet = taskDlg.DoModal();
* switch (nRet)
* {
* case 0:
* AfxMessageBox(_T("Task Dialog could not be created!"));
* break;
* case IDOK:
* // the user pressed the OK button, change password.
* break;
* case IDCANCEL:
* // user canceled the dialog.
* break;
* };
*
*/
virtual INT_PTR DoModal();
/**
* @brief
* Call this member function to display the task dialog and return
* the selected button when done.
* @param bUseComCtl32 TRUE to use the ComCtl32.dll version of Task Dialog. This
* parameter is ignored for operating systems older than
* Windows Vista.
* @return
* The return value is one of the button IDs specified in the AddButton
* member function or one of the following values:
*
* 0: Function call failed.
* IDCANCEL: Cancel button was selected, Alt-F4 was pressed, Escape was
* pressed, or the user clicked on the close window button.
* IDNO: No button was selected.
* IDOK: OK button was selected.
* IDRETRY: Retry button was selected.
* IDYES: Yes button was selected.
* Example:
*
* CXTPTaskDialog taskDlg(this);
* taskDlg.AddButton(_T(\"Change password"), IDOK);
* taskDlg.SetCommonButtons(TDCBF_CANCEL_BUTTON);
* taskDlg.SetMainIcon(TD_WARNING_ICON);
* taskDlg.SetMainInstruction(_T("Change Password"));
* taskDlg.SetContent(_T("Remember your changed password."));
*
* int nRet = taskDlg.DoModal();
* switch (nRet)
* {
* case 0:
* AfxMessageBox(_T("Task Dialog could not be created!"));
* break;
* case IDOK:
* // the user pressed the OK button, change password.
* break;
* case IDCANCEL:
* // user canceled the dialog.
* break;
* };
*
*/
INT_PTR DoModal(BOOL bUseComCtl32);
/**
* @brief
* Call this member function to create a modeless task dialog.
* @param pParentWnd Parent Window.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL Create(CWnd* pParentWnd = NULL);
# if _MSC_VER > 1200
using CDialog::Create;
using CWnd::Create;
# endif
/**
* @brief
* Call this member function to retrieve the ID of the button used
* to close the task dialog.
* @return
* The return value is one of the button IDs specified in the AddButton
* member function or one of the following values:
*
* 0: Function call failed.
* IDCANCEL: Cancel button was selected, Alt-F4 was pressed, Escape was
* pressed, or the user clicked on the close window button.
* IDNO: No button was selected.
* IDOK: OK button was selected.
* IDRETRY: Retry button was selected.
* IDYES: Yes button was selected.
* @see
* AddButton, EnableCommandLinks, SetDefaultButton, SetCommonButtons,
* OnButtonClicked, ClickButton, EnableButton, SetButtonElevationRequired
*/
int GetSelectedButtonId() const;
/**
* @brief
* Call this member function to retrieve the ID of the radio button
* that was selected when the task dialog was closed.
* @return
* The return value is one of the button IDs specified in the
* AddRadioButton member function.
* @see
* AddRadioButton, SetDefaultRadioButton, NoDefaultRadioButton,
* OnRadioButtonClicked, ClickRadioButton, EnableRadioButton
*/
int GetSelectedRadioButtonId() const;
/**
* @brief
* Call this member function to retrieve the checked state of the
* verification checkbox when the dialog was closed.
* @return
* TRUE if the verification check box was checked when the task
* dialog was closed, otherwise FALSE.
* @see
* SetVerificationText, SetVerifyCheckState, OnVerificationClicked,
* ClickVerification
*/
BOOL IsVerificiationChecked() const;
/**
* @brief
* Call this member function to modify the style for the task dialog.
* @param dwRemove Specifies the styles to be removed.
* @param dwAdd Specifies the styles to be added.
* @details
* Styles to be added or removed can be combined by using the bitwise
* OR (|) operator. The style can be any combination of the following
* values:
*
* TDF_ENABLE_HYPERLINKS: See EnableHyperlinks.
* TDF_USE_HICON_MAIN: See SetMainIcon.
* TDF_USE_HICON_FOOTER: See SetFooterIcon.
* TDF_ALLOW_DIALOG_CANCELLATION: See EnableCancellation.
* TDF_USE_COMMAND_LINKS: See EnableCommandLinks.
* TDF_USE_COMMAND_LINKS_NO_ICON: See EnableCommandLinks.
* TDF_EXPAND_FOOTER_AREA: See ExpandFooterArea.
* TDF_EXPANDED_BY_DEFAULT: See ExpandedByDefault.
* TDF_VERIFICATION_FLAG_CHECKED: See SetVerifyCheckState.
* TDF_SHOW_PROGRESS_BAR: See ShowProgressBar.
* TDF_SHOW_MARQUEE_PROGRESS_BAR: See ShowProgressBar.
* TDF_CALLBACK_TIMER: See EnableCallbackTimer.
* TDF_POSITION_RELATIVE_TO_WINDOW: See EnableRelativePosition.
* TDF_RTL_LAYOUT: See EnableRtlLayout.
* TDF_NO_DEFAULT_RADIO_BUTTON: See NoDefaultRadioButton.
* TDF_CAN_BE_MINIMIZED: See EnableMinimize.
* @return
* TRUE if style was successfully modified, otherwise FALSE.
*/
BOOL ModifyTaskStyle(TASKDIALOG_FLAGS dwRemove, TASKDIALOG_FLAGS dwAdd);
/**
* @brief
* Call this member function to simulate the action of a button click
* in the task dialog.
* @param nButtonID Indicates the button ID to be selected.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CSimulateClickDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* BOOL bClick = TRUE;
* if (bClick)
* {
* ClickButton(IDCANCEL);
* }
* }
* };
*
* @see
* AddButton, EnableCommandLinks, SetDefaultButton, SetCommonButtons,
* GetSelectedButtonId, OnButtonClicked, EnableButton, SetButtonElevationRequired
*/
void ClickButton(int nButtonID);
/**
* @brief
* Call this member function to simulate the action of a radio button click
* in the task dialog.
* @param nButtonID Indicates the radio button ID to be selected.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CSimulateClickDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* BOOL bClick = TRUE;
* if (bClick)
* {
* ClickRadioButton(100);
* }
* }
* };
*
* @see
* AddRadioButton, SetDefaultRadioButton, NoDefaultRadioButton,
* GetSelectedRadioButtonId, OnRadioButtonClicked, EnableRadioButton
*/
void ClickRadioButton(int nButtonID);
/**
* @brief
* Call this member function to simulate the action of clicking the
* verification checkbox in the task dialog.
* @param bChecked TRUE to set the state of the checkbox to be checked, or
* FALSE to set it to be unchecked.
* @param bSetKeyFocus TRUE to set the keyboard focus to the checkbox, or
* FALSE otherwise.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CSimulateClickDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* BOOL bClick = TRUE;
* if (bClick)
* {
* ClickVerification(TRUE, FALSE);
* }
* }
* };
*
* @see
* SetVerificationText, SetVerifyCheckState, IsVerificiationChecked,
* OnVerificationClicked
*/
void ClickVerification(BOOL bChecked, BOOL bSetKeyFocus);
/**
* @brief
* Call this member function to enable/disable a push button in
* the task dialog.
* @param nButtonID Indicates the ID of the push button to be enabled/disabled.
* @param bEnable TRUE to enable the button, FALSE to disable the button.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CEnableButtonDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* EnableButton(IDOK, FALSE);
* }
* };
*
* @see
* AddButton, EnableCommandLinks, SetDefaultButton, SetCommonButtons,
* GetSelectedButtonId, ClickButton, OnButtonClicked, SetButtonElevationRequired
*/
void EnableButton(int nButtonID, BOOL bEnable = TRUE);
/**
* @brief
* Call this member function to enable/disable a radio button in
* the task dialog.
* @param nButtonID Indicates the ID of the radio button to be enabled/disabled.
* @param bEnable TRUE to enable the radio button, FALSE to disable the radio button.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CEnableRadioButtonDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* EnableRadioButton(100, FALSE);
* }
* };
*
* @see
* AddRadioButton, SetDefaultRadioButton, NoDefaultRadioButton,
* GetSelectedRadioButtonId, ClickRadioButton, OnRadioButtonClicked
*/
void EnableRadioButton(int nButtonID, BOOL bEnable = TRUE);
/**
* @brief
* Call this member function to indicate whether the progress bar should
* be displayed in marquee mode or not.
* @param bMarquee Specifies whether the progress bar should be shown in
* Marquee mode. A value of TRUE turns on Marquee mode.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CProgressDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* SetMarqueeProgressBar(TRUE);
* SetProgressBarState(PBST_NORMAL);
* }
* };
*
* @see
* ShowProgressBar, SetProgressBarState, SetProgressBarRange,
* SetProgressBarPos, StartProgressBarMarquee
*/
void SetMarqueeProgressBar(BOOL bMarquee = TRUE);
/**
* @brief
* Call this member function to set the current state of the
* progress bar.
* @param nState Specifies the bar state. The parameter can be one of the
* following values:
*
* PBST_NORMAL: Sets the progress bar to the normal state.
* PBST_PAUSE: Sets the progress bar to the paused state.
* PBST_ERROR: Set the progress bar to the error state.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CProgressDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* SetProgressBarPos(25);
* SetProgressBarRange(0, 100);
* SetProgressBarState(PBST_PAUSE);
* }
* };
*
* @see
* SetMarqueeProgressBar, ShowProgressBar, SetProgressBarRange,
* SetProgressBarPos, StartProgressBarMarquee
*/
void SetProgressBarState(int nState);
/**
* @brief
* Call this member function to set the minimum and maximum values
* for the progress bar.
* @param wMinRange Minimum range value. By default, the minimum value is zero.
* @param wMaxRange Maximum range value. By default, the maximum value is 100.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CProgressDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* SetProgressBarPos(25);
* SetProgressBarRange(0, 100);
* SetProgressBarState(PBST_PAUSE);
* }
* };
*
* @see
* SetMarqueeProgressBar, SetProgressBarState, ShowProgressBar,
* SetProgressBarPos, StartProgressBarMarquee
*/
void SetProgressBarRange(WORD wMinRange = 0, WORD wMaxRange = 100);
/**
* @brief
* Call this member function to se the current position for the
* progress bar.
* @param nPosition Signed integer that becomes the new position.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CProgressDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* SetProgressBarPos(25);
* SetProgressBarRange(0, 100);
* SetProgressBarState(PBST_PAUSE);
* }
* };
*
* @see
* SetMarqueeProgressBar, SetProgressBarState, SetProgressBarRange,
* ShowProgressBar, StartProgressBarMarquee
*/
void SetProgressBarPos(int nPosition);
/**
* @brief
* Similar to SetMarqueeProgressBar; this member function is used to
* indicate whether the progress bar should be displayed in marquee
* mode or not with the ability to determine marquee speed as well.
* @param bStartMarquee Indicates whether to start marquee.
* @param dwMilliSeconds Indicates the speed of the marquee in milliseconds.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CProgressDlg : public CXTPTaskDialog
* {
* protected:
* virtual void OnDialogConstructed()
* {
* StartProgressBarMarquee(TRUE, 10);
* SetProgressBarState(PBST_NORMAL);
* }
* };
*
* @see
* SetMarqueeProgressBar, SetProgressBarState, SetProgressBarRange,
* SetProgressBarPos, ShowProgressBar
*/
void StartProgressBarMarquee(BOOL bStartMarquee, DWORD dwMilliSeconds);
/**
* @brief
* Call this member function to designate whether a given Task Dialog
* button or command link should have a User Account Control (UAC)
* shield icon (whether the action invoked by the button requires elevation).
* @param nButtonID Indicates ID of the push button or command link to be updated.
* @param bRequired TRUE to designate that the action invoked by the button requires
* elevation, FALSE to designate that the action invoked by
* the button does not require elevation.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CElevationDlg : public CXTPTaskDialog
* {
* protected:
* void OnButtonClicked(int nButtonID, BOOL& bCloseDialog)
* {
* switch (nButtonID)
* {
* case IDOK:
* SetButtonElevationRequired(nButtonID, TRUE);
* bCloseDialog = FALSE;
* break;
* case IDCANCEL:
* SetButtonElevationRequired(nButtonID, FALSE);
* bCloseDialog = TRUE;
* break;
* }
* }
* };
*
* @see
* AddButton, EnableCommandLinks, SetDefaultButton, SetCommonButtons,
* GetSelectedButtonId, ClickButton, EnableButton, OnButtonClicked
*/
void SetButtonElevationRequired(int nButtonID, BOOL bRequired = TRUE);
/**
* @brief
* This member function is used to simulate a wizard style task dialog.
* By using multiple CXTPTaskDialog objects that define the aspects
* of each page, you can incorporate Back and Next buttons that can
* be used to update the appearance and behavior of the task dialog.
* @param taskDlg Reference to a CXTPTaskDialog object that contains
* attributes for the appearance and behavior of the new
* task page.
* @details
* This member function should only be called from a derived class,
* and only after the task dialog has been initialized.
* Example:
*
* class CNavigateDlg : public CXTPTaskDialog
* {
* CXTPTaskDialog m_dlgBack;
* CXTPTaskDialog m_dlgNext;
* protected:
* void OnButtonClicked(int nButtonID, BOOL& bCloseDialog)
* {
* switch (nButtonID)
* {
* case IDBACK:
* NavigatePage(m_dlgBack);
* bCloseDialog = FALSE;
* break;
* case IDNEXT:
* NavigatePage(m_dlgNext);
* bCloseDialog = FALSE;
* break;
* }
* }
* };
*
* @see
* OnNavigated
*/
void NavigatePage(CXTPTaskDialog& taskDlg);
/**
* @brief
* Call this member function to reset the configuration attributes for
* the task dialog to the default state.
*/
void ResetContent();
/**
* @brief
* Enables/disables message box like style for the dialog. If enabled, then
* the background, fonts, and buttons' appearance will match the system
* message box apperance.
* @param bEnable TRUE to enable the style, FALSE to disable.
*/
void EnableMessageBoxStyle(BOOL bEnable = TRUE);
/**
* @brief
* Call this method to create a dialog from an XML resource.
* @param nIDResource Resource identifier.
* @param lpszDialog Dialog XML section.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL CreateFromResource(UINT nIDResource, LPCTSTR lpszDialog);
/**
* @brief
* Call this method to create a dialog from an XML resource.
* @param hInstance Instance of resources.
* @param nIDResource Resource identifier.
* @param lpszDialog Dialog XML section.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL CreateFromResource(HINSTANCE hInstance, UINT nIDResource, LPCTSTR lpszDialog);
/**
* @brief
* Call this method to create a dialog from an XML resource.
* @param hInstance Instance of resources.
* @param nIDResource Resource identifier.
* @param lpszDialog Dialog XML section.
* @param rglpsz Array of strings that will be replaced with XML strings.
* @param nString Number of parameter strings.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL CreateFromResourceParam(HINSTANCE hInstance, UINT nIDResource, LPCTSTR lpszDialog,
LPCTSTR const* rglpsz, int nString);
/**
* @brief
* Call this method to create a dialog from an XML resource.
* @param pPX CXTPPropExchangeXMLNode node.
* @param rglpsz Array of strings that will be replaced with XML strings.
* @param nString Number of parameter strings.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL CreateFromResourceParam(CXTPPropExchangeXMLNode* pPX, LPCTSTR const* rglpsz, int nString);
protected:
/**
* @brief
* This notification is sent by the Task Dialog when the task dialog
* has been created and before it is displayed.
* @see
* SetWidth, EnableCancellation, EnableRelativePosition,
* EnableRtlLayout, EnableMinimize, SetWindowTitle
*/
virtual void OnDialogConstructed();
/**
* @brief
* This notification is sent by the Task Dialog when the task dialog
* has been destroyed.
* @see
* OnDialogConstructed
*/
virtual void OnDialogDestroyed();
/**
* @brief
* This notification is sent by the Task Dialog when a user clicks
* on a hyperlink in the Task Dialog's content.
* @param pszURL Pointer to a wide-character string containing the URL
* of the hyperlink.
* @see
* SetContent, SetExpandedInformation, SetFooter, EnableHyperlinks
*/
virtual void OnHyperlinkClicked(LPCTSTR pszURL);
/**
* @brief
* This notification is sent by the Task Dialog when a user selects
* a button or command link in the task dialog.
* @param nButtonID The ID corresponding to the button selected.
* @param bCloseDialog Set to TRUE if the task dialog should close.
* @see
* AddButton, EnableCommandLinks, SetDefaultButton, SetCommonButtons,
* GetSelectedButtonId, ClickButton, EnableButton, SetButtonElevationRequired
*/
virtual void OnButtonClicked(int nButtonID, BOOL& bCloseDialog);
/**
* @brief
* This notification is sent by the Task Dialog when a user selects
* a radio button in the task dialog.
* @param nButtonID The ID corresponding to the radio button that was clicked.
* @see
* AddRadioButton, SetDefaultRadioButton, NoDefaultRadioButton,
* GetSelectedRadioButtonId, ClickRadioButton, EnableRadioButton
*/
virtual void OnRadioButtonClicked(int nButtonID);
/**
* @brief
* This notification is sent by the Task Dialog when the user clicks
* on the task dialog's verification check box.
* @param bChecked TRUE if the verification checkbox is checked, otherwise FALSE.
* @see
* SetVerificationText, SetVerifyCheckState, IsVerificiationChecked,
* ClickVerification
*/
virtual void OnVerificationClicked(BOOL bChecked);
/**
* @brief
* This notification is sent by the Task Dialog when the user presses
* F1 on the keyboard while the dialog has focus.
*/
virtual void OnHelp();
/**
* @brief
* This notification is sent by the Task Dialog when the value
* of the input box has changed.
*/
virtual void OnInputBoxChanged();
/**
* @brief
* This notification is sent by the Task Dialog when the user clicks
* on an expando in the Task Dialog.
* @param bExpanded TRUE if the dialog is expanded, otherwise FALSE.
* @see
* SetCollapsedControlText, SetExpandedInformation, ExpandedByDefault,
* ExpandFooterArea, SetExpandedControlText
*/
virtual void OnExpandoButtonClicked(BOOL bExpanded);
/**
* @brief
* This notification is sent by the Task Dialog approximately every
* 200 milliseconds when the EnableCallbackTimer member function has
* been called.
* @param dwMilliSeconds Number of milliseconds since the dialog was created
* or bReset was set to TRUE.
* @param bReset TRUE to reset the tickcount, otherwise the tickcount
* will continue to increment.
* @see
* EnableCallbackTimer, ModifyTaskStyle
*/
virtual void OnTimer(DWORD dwMilliSeconds, BOOL& bReset);
/**
* @brief
* This notification is sent by the Task Dialog when a navigation
* has occurred.
* @see
* NavigatePage
*/
virtual void OnNavigated();
/**
* @brief
* This virtual method is called when some notification is sent from TaskDialog.
* @param uNotification Notification identifier.
* @param wParam Extended parameter of notification.
* @param lParam Extended parameter of notification.
* @return
* S_OK if successful.
* @see
* OnDialogConstructed, OnNavigated, OnButtonClicked, OnHyperlinkClicked,
* OnTimer, OnRadioButtonClicked, OnVerificationClicked, OnExpandoButtonClicked
*/
virtual HRESULT OnDialogNotify(UINT uNotification, WPARAM wParam, LPARAM lParam);
protected:
int m_nSelButtonID; /**< ID of the button that was selected when the task dialog was closed. */
HWND m_hwndTaskDialog; /**< Real window handle of TaskDialog. */
TASKDIALOGCONFIG m_config; /**< Structure containing information used to display a task dialog.
*/
CArray