如何设置复选按钮的选中和未选中状态?在线等
如题,((CButton*)GetDlgItem(IDC_CHECK_CHANGED))->SetCheck(BST_CHECKED);为什么没有反应呢?应该使用哪个函数呢?
在线等。
问题点数:60、回复次数:10Top
1 楼laiyiling(陌生人[MVP])回复于 2005-04-03 20:32:07 得分 10
CheckDlgButton( IDC_CHECKBOX1, BST_CHECKED );
CheckDlgButton( IDC_CHECKBOX2, BST_UNCHECKED );Top
2 楼dfyang()回复于 2005-04-03 21:22:29 得分 10
((CButton*)GetDlgItem(IDC_CHECK_CHANGED))->SetCheck(TRUE);
((CButton*)GetDlgItem(IDC_CHECK_CHANGED))->SetCheck(FALSE);各试一下Top
3 楼kugou123(酷狗)(彪悍的人生,不需要解释 www.xiaozhou.net)回复于 2005-04-03 21:56:45 得分 10
不如写分开来试试:
CButton *pCheck=NULL;
pCheck=GetDlgItem(IDC_CHECK_CHANGE);
pCheck->SetCheck(1);Top
4 楼sjcode(愚者)回复于 2005-04-03 22:05:58 得分 10
你把它的数据类型设为BOOL
通过赋值TRUE/FALSE与UpdateData()来完成它的刷新
Top
5 楼hiiiiiijiang(等待毕业)回复于 2005-04-03 23:17:03 得分 10
恩,楼上的方法简单些Top
6 楼bigant888(比熊牛,比牛熊)回复于 2005-04-03 23:23:27 得分 10
CButton::SetCheck
void SetCheck( int nCheck );
Parameters
nCheck
Specifies the check state. This parameter can be one of the following:
Value Meaning
0 Set the button state to unchecked.
1 Set the button state to checked.
2 Set the button state to indeterminate. This value can be used only if the button has the BS_3STATE or BS_AUTO3STATE style.
Remarks
Sets or resets the check state of a radio button or check box. This member function has no effect on a pushbutton.
Top
7 楼gdsdyl(晚来天欲雪,能饮一杯无?)回复于 2005-04-03 23:49:03 得分 0
你设置复选按钮的方法没错,只是在设置完成后,用Invalidate()使窗口刷新,即可。Top
8 楼zhenjie(zhenjie)回复于 2005-04-04 10:24:22 得分 0
别忘记了调用UpdateData(FALSE);刷新函数。Top
9 楼koko1998(高价购买火车票)回复于 2005-04-04 11:01:40 得分 0
应该没有问题的啊,是不是你其他的地方也处理了
Top
10 楼oyljerry(【勇敢的心】→ ㊣提拉米苏√㊣)回复于 2005-04-04 12:28:18 得分 0
检查是否正确获得控件对象指针,然后SetCheckTop




