1.建立一個基於對話框的用用程序,在其中加入三個Radio Button,ID分別為: IDC_RADIO1,IDC_RADIO2,IDC_RADIO3 2.控件的初始化: 在對話框類的OnInitDialog中加入代碼: CheckRadioButton(IDC_RADIO1, //第一個參數為該組的第一個單選按鈕的ID IDC_RADIO3, //第二個參數為該組的最后一個單選按鈕的ID IDC_RADIO3); //第三個參數為該組中被選中的單選按鈕的ID 3.在加入一個Button控件,並為其寫入Click事件代碼: int iRadioButton; iRadioButton=GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO3); if(iRadioButton==IDC_RADIO1) MessageBox("Click Button1"); if(iRadioButton==IDC_RADIO2) MessageBox("Click Button2"); if(iRadioButton==IDC_RADIO3) MessageBox("Click Button3");
