3 out of 3 rated this helpful - Rate this topic

TaskDialogIndirect function

Applies to: desktop apps only

The TaskDialogIndirect function creates, displays, and operates a task dialog. The task dialog contains application-defined icons, messages, title, verification check box, command links, push buttons, and radio buttons. This function can register a callback function to receive notification messages.

Syntax

HRESULT TaskDialogIndirect(
  __in       const TASKDIALOGCONFIG *pTaskConfig,
  __out_opt  int *pnButton,
  __out_opt  int *pnRadioButton,
  __out_opt  BOOL *pfVerificationFlagChecked
);

Parameters

pTaskConfig [in]

Type: const TASKDIALOGCONFIG*

Pointer to a TASKDIALOGCONFIG structure that contains information used to display the task dialog.

pnButton [out, optional]

Type: int*

Address of a variable that receives either:

  • one of the button IDs specified in the pButtons member of the pTaskConfig parameter
  • one of the following values:
ValueDescription
0Function call failed. Refer to return value for more information.
IDCANCELCancel button was selected, Alt-F4 was pressed, Escape was pressed or the user clicked on the close window button.
IDNONo button was selected.
IDOKOK button was selected.
IDRETRYRetry button was selected.
IDYESYes button was selected.

 

If this parameter is NULL, no value is returned.

pnRadioButton [out, optional]

Type: int*

Address of a variable that receives one of the button IDs specified in the pRadioButtons member of the pTaskConfig parameter. If this parameter is NULL, no value is returned.

pfVerificationFlagChecked [out, optional]

Type: BOOL*

Address of a variable that receives one of the following values.

ValueDescription
TRUEThe verification checkbox was checked when the dialog was dismissed.
FALSEThe verification checkbox was not checked when the dialog was dismissed.

 

If this parameter is NULL, the verification checkbox is disabled.

Return value

Type: HRESULT

This function can return one of these values.

Return codeDescription
S_OK

The operation completed successfully.

E_OUTOFMEMORY

There is insufficient memory to complete the operation.

E_INVALIDARG

One or more arguments are not valid.

E_FAIL

The operation failed.

 

Remarks

When you use a task dialog box to indicate that the system is low on memory, the strings pointed to by the various string and icon members in the TASKDIALOGCONFIG structure 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.

The parent window should not be hidden or disabled when this function is called.



int nButtonPressed                  = 0;
TASKDIALOGCONFIG config             = {0};
const TASKDIALOG_BUTTON buttons[]   = { 
                                        { IDOK, L"Change password" }
                                      };
config.cbSize                       = sizeof(config);
config.hInstance                    = hInst;
config.dwCommonButtons              = TDCBF_CANCEL_BUTTON;
config.pszMainIcon                  = TD_WARNING_ICON;
config.pszMainInstruction           = L"Change Password";
config.pszContent                   = L"Remember your changed password.";
config.pButtons                     = buttons;
config.cButtons                     = ARRAYSIZE(buttons);

TaskDialogIndirect(&config, &nButtonPressed, NULL, NULL);
switch (nButtonPressed)
{
    case IDOK:
        break; // the user pressed button 0 (change password).
    case IDCANCEL:
        break; // user canceled the dialog
    default:
        break; // should never happen
}

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Commctrl.h (include Commctrl.h)

Library

Comctl32.lib

DLL

Comctl32.dll version 6

See also

Dialog Boxes

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
You can't hide the system icon in the nonclient area if there is an ICANCEL button
If you put any button with in the TASKDIALOGCONFIG with an ID of IDCANCEL, the system icon in the nonclient area will show up and the system menu will contain a value of "close".  Even if you don't set hMainIcon, you'll get the default taskdialog icon, there's no way to hide the icon at all if any button has IDCANCEL.  If you want no icon at all, you can't have a button with IDCANCEL, you'll need to change its ID to something else.