我做一个VC应用程序,在CConAdminView类中添加CButton *m_btn变量。
然后在OnCreate函数中添加代码如下:
m_btn=new CButton[10];//新建按钮
for(int i=5;i<9;i++){//用后面的4个变量创建为单选框
m_btn[i].Create(caption[i],BS_RADIOBUTTON | WS_CHILD |WS_VISIBLE,
CRect(0,0,0,0),this,1055);
m_btn[i].MoveWindow(m_clientRect.right-500+(i-5)*125,0,125,20);
}
但出现了这样的问题。
4个单选框能够显示出来,但点击无法响应。无论怎么操作都不能使一个按钮处于选中状态。
请各位高手指点一二,万分感激!

解决方案 »

  1.   

    不要用BS_RADIOBUTTON,用BS_AUTORADIOBUTTON
      

  2.   

    BS_AUTORADIOBUTTON 
    Creates a button that is the same as a radio button, except that when the user selects it, The system automatically sets the button's check state to checked and automatically sets the check state for all other buttons in the same group to cleared.
      

  3.   

    TAB的顺序(就是Ctrl+D)不连续就可以了
      

  4.   


    给第一个不相关的Button增加WS_GROUP属性即可,即BS_AUTORADIOBUTTON | WS_GROUP
      

  5.   

    LZ的Button都创建成同一ID了(最后一个参数)。
      

  6.   

    把按钮的属性设置为:BS_AUTORADIOBUTTON。如果有多组则在每一组的第一个按钮的属性设置为WS_GROUP即可。