我做一个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个单选框能够显示出来,但点击无法响应。无论怎么操作都不能使一个按钮处于选中状态。
请各位高手指点一二,万分感激!
然后在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个单选框能够显示出来,但点击无法响应。无论怎么操作都不能使一个按钮处于选中状态。
请各位高手指点一二,万分感激!
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.
给第一个不相关的Button增加WS_GROUP属性即可,即BS_AUTORADIOBUTTON | WS_GROUP