Condividi tramite


CTaskDialog::SetCommonButtonOptions

Updates a subset of common buttons to be enabled and to require UAC elevation.

void SetCommonButtonOptions(
   int nDisabledButtonMask,
   int nElevationButtonMask = 0
);

Parameters

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

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

Remarks

You can set the common buttons available to an instance of the CTaskDialog Class by using the constructor CTaskDialog::CTaskDialog and the method CTaskDialog::SetCommonButtons. CTaskDialog::SetCommonButtonOptions does not support adding new common buttons.

If you use this method to disable or elevate a common button that is not available for this CTaskDialog, this method throws an exception by using the ENSURE (MFC) macro.

This method enables any button that is available to the CTaskDialog but is not in the nDisabledButtonMask, even if it was previously disabled. This method treats elevation in a similar manner: it records common buttons as not requiring elevation if the common button is available but not included in nElevationButtonMask.

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::CTaskDialog

CTaskDialog::SetCommonButtons