Condividi tramite


CTaskDialog::SetCommonButtons

Adds common buttons to the CTaskDialog.

void SetCommonButtons(
   int nButtonMask,
   int nDisabledButtonMask = 0,
   int nElevationButtonMask = 0
);

Parameters

  • [in] nButtonMask
    A mask of the buttons to add to the CTaskDialog.

  • [in] nDisabledButtonMask
    A mask of the buttons to disable.

  • [in] nElevationButtonMask
    A mask of the buttons that require elevation.

Remarks

You cannot call this method after the display window for this instance of the CTaskDialog Class is created. If you do, this method throws an exception.

The buttons indicated by nButtonMask override any common buttons previously added to the CTaskDialog. Only the buttons indicated in nButtonMask are available.

If either nDisabledButtonMask or nElevationButtonMask contain a button that is not in nButtonMask, this method throws an exception by using the ENSURE (MFC) macro.

By default, all common buttons are enabled and do not require elevation.

Example

// 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);

// Create a button mask.
int buttons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON;
buttons |= TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;

taskDialog.SetCommonButtons(buttons);

// Disable the close button and make the retry button require 
// elevation.
taskDialog.SetCommonButtonOptions(TDCBF_CLOSE_BUTTON, 
    TDCBF_RETRY_BUTTON);

taskDialog.DoModal();

Requirements

Header: afxtaskdialog.h

See Also

Reference

CTaskDialog Class

Hierarchy Chart

CTaskDialog::SetCommonButtonOptions