다음을 통해 공유


CTaskDialog::LoadRadioButtons

문자열 테이블에서 데이터를 사용 하 여 라디오 단추 컨트롤을 추가 합니다.

void LoadRadioButtons(
   int nIDRadioButtonsFirst,
   int nIDRadioButtonsLast
);

매개 변수

  • [in] nIDRadioButtonsFirst
    첫 번째 라디오 버튼의 문자열 ID입니다.

  • [in] nIDRadioButtonsLast
    마지막으로 라디오 버튼의 문자열 ID입니다.

설명

이 메서드는 응용 프로그램의 리소스 파일에서 데이터를 사용 하 여 라디오 단추를 만듭니다.문자열 테이블 리소스 파일에서 여러 문자열 연결 문자열 id가 있습니다.이 메서드를 사용 하 여 추가 된 새 라디오 단추 문자열 라디오 단추의 캡션 및 문자열 ID에 대 한 라디오 버튼의 ID를 사용선택 된 문자열의 범위를 제공 nIDRadioButtonsFirst 및 nRadioButtonsLast을 포함 합니다.메서드 범위에 빈 항목이 있으면 해당 항목에 대 한 라디오 단추를 추가 하지 않습니다.

기본적으로는 새 라디오 단추가 활성화 됩니다.

예제

// 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.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

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

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

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

default:
    break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303, 
    L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

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

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch(taskDialog.GetSelectedRadioButtonID())
{
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 radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

요구 사항

헤더: afxtaskdialog.h

참고 항목

참조

CTaskDialog 클래스

계층 구조 차트

CTaskDialog::AddRadioButton

CTaskDialog::SetRadioButtonOptions

CTaskDialog::RemoveAllRadioButtons