다음을 통해 공유


CTaskDialog::AddCommandControl

새 명령 단추 컨트롤에 추가 된 CTaskDialog.

void AddCommandControl(
   int nCommandControlID,
   const CString& strCaption,
   BOOL bEnabled = TRUE,
   BOOL bRequiresElevation = FALSE
);

매개 변수

  • [in] nCommandControlID
    명령 컨트롤의 id 번호입니다.

  • [in] strCaption
    문자열에는 CTaskDialog 사용자에 게 표시 됩니다.명령의 용도 설명 하기 위해이 문자열을 사용 합니다.

  • [in] bEnabled
    새 단추 설정 또는 해제 여부를 나타내는 부울 매개 변수입니다.

  • [in] bRequiresElevation
    명령 권한 상승이 필요한 지 여부를 나타내는 부울 매개 변수입니다.

설명

CTaskDialog 클래스 무제한으로 명령 단추 컨트롤을 표시할 수 있습니다.그러나 경우에 CTaskDialog 표시 된 명령 단추 컨트롤, 최대 6 개의 단추를 표시할 수 있습니다.경우는 CTaskDialog 명령 단추 컨트롤이, 무수히 많은 단추를 표시할 수 있습니다.

명령 단추 컨트롤을 선택할 때의 CTaskDialog 를 닫습니다.대화 상자를 사용 하 여 응용 프로그램을 표시 하는 경우 CTaskDialog::DoModal, DoModal 반환 된 nCommandControlID 선택한 명령 단추 컨트롤의.

예제

// 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, 
    TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON );

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch(selection)
{
case 201:
    // TODO: Place processing here for the first 
    // command button control.
    break;

case 202:
    // TODO: Place processing here for the second 
    // command button control.
    break;

case 203:
    // TODO: Place processing here for the third 
    // command button control.
    break;

default:
    break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301, 
    L"New first command button control");
taskDialog.AddCommandControl(302, 
    L"New second command button control should require elevation",
    TRUE, TRUE);
taskDialog.AddCommandControl(303, 
    L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
    taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch(taskDialog.GetSelectedCommandControlID())
{
case 301:
    // TODO: Place processing here for new first 
    // command button control.
    break;

case 302:
    // TODO: Place processing here for new second 
    // command button control.
    break;

case 303:
    // TODO: Place processing here for the new third 
    // command button control.
    break;

default:
    break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

요구 사항

헤더: afxtaskdialog.h

참고 항목

참조

CTaskDialog 클래스

계층 구조 차트

CTaskDialog::ClickCommandControl

CTaskDialog::GetSelectedCommandControlID

CTaskDialog::IsCommandControlEnabled

CTaskDialog::RemoveAllCommandControls

CTaskDialog::SetCommandControlOptions

CTaskDialog::SetDefaultCommandControl