如何以程序的方式选中特定的单选框?比如有好几个单选按钮,用程序怎么使某一个被选中?

解决方案 »

  1.   

    GetDlgItem(IDC_RADIO1)->SetCheck(1);
      

  2.   

    CWnd::CheckRadioButton  
    void CheckRadioButton( int nIDFirstButton, int nIDLastButton, int nIDCheckButton );ParametersnIDFirstButtonSpecifies the integer identifier of the first radio button in the group.nIDLastButtonSpecifies the integer identifier of the last radio button in the group.nIDCheckButtonSpecifies the integer identifier of the radio button to be checked.ResSelects (adds a check  to) a given radio button in a group and clears (removes a check  from) all other radio buttons in the group. The CheckRadioButton function sends aBM_SETCHECK message to the specified radio button.Example// Of the 4 radio buttons, selects radio button 3.
    void CMyDlg::OnMarkRadio() 
    {
       CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO3);   
    }
      

  3.   


      我对Radio加了消息处理函数,怎样才能让通过程序选中并执行相应的函数呢?