The TaskDialog function creates, displays, and operates a task dialog. The task dialog contains application-defined message text and title, icons, and any combination of predefined push buttons. This function does not support the registration of a callback function to receive notifications.
HRESULT TaskDialog( HWND hwndOwner, HINSTANCE hInstance, PCWSTR pszWindowTitle, PCWSTR pszMainInstruction, PCWSTR pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, PCWSTR pszIcon, int *pnButton );
Handle to the owner window of the task dialog to be created. If this parameter is NULL, the task dialog has no owner window.
Handle to the module that contains the icon resource identified by the pszIcon member, and the string resources identified by the pszWindowTitle and pszMainInstruction members. If this parameter is NULL, pszIcon must be NULL or a pointer to a null-terminated, Unicode string that contains a system resource identifier, for example, TD_ERROR_ICON.
Pointer to the string to be used for the task dialog title. This parameter is a null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. If this parameter is NULL, the filename of the executable program is used.
Pointer to the string to be used for the main instruction. This parameter is a null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. This parameter can be NULL if no main instruction is wanted.
Pointer to a string used for additional text that appears below the main instruction, in a smaller font. This parameter is a null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. Can be NULL if no additional text is wanted.
Specifies the push buttons displayed in the dialog box. This parameter may be a combination of flags from the following group.
Pointer to a string that identifies the icon to display in the task dialog. This parameter must be an integer resource identifier passed to the MAKEINTRESOURCE macro or one of the following predefined values. If this parameter is NULL, no icon will be displayed. If the hInstance parameter is NULL and one of the predefined values is not used, the TaskDialog function fails.
When this function returns, contains a pointer to an integer location that receives one of the following values:
|0||Function call failed. Refer to return value for more information.|
|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.|
If this value is NULL, no value is returned.
This function can return one of these values.
||The operation completed successfully.|
||There is insufficient memory to complete the operation.|
||One or more arguments are not valid.|
||The operation failed.|
When you use a task dialog box to indicate that the system is low on memory, the strings pointed to by the pszMainInstruction and pszWindowTitle parameters should not be taken from a resource file since an attempt to load the resource may fail.
If you create a task dialog while a dialog box is present, use a handle to the dialog box as the hWndParent parameter. The hWndParent parameter should not identify a child window, such as a control in a dialog box.
Because task dialog boxes use the correct system-defined UI elements, you should use them instead of using message boxes created with the MessageBox function. To achieve more functionality, use TaskDialogIndirect.
The following example code, to be included as part of a larger program, shows how to create a task dialog and capture input.
int nButtonPressed = 0; TaskDialog(NULL, hInst, MAKEINTRESOURCE(IDS_APPLICATION_TITLE), MAKEINTRESOURCE(IDS_DOSOMETHING), MAKEINTRESOURCE(IDS_SOMECONTENT), TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON, TD_WARNING_ICON, &nButtonPressed);
|Windows version||Windows Vista [desktop apps only] Windows Server 2008 [desktop apps only]|
|Header||commctrl.h (include Commctrl.h)|
|DLL||Comctl32.dll (version 6)|