MFC Radio button 的使用


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM