VC6.0可用的代码段:
CButton *pButton = (CButton *)GetDlgItem(checkbox的ID); //获得指定IDcheckbox对象引用,并转换为CButton对象
int i = pButton->GetCheck();//获得checkbox的点击状态,值只有0 1 2三种状态,点击后为非0值
i得到的值就是checkbox的选定值;
GetDlgItem
CButton::GetCheck
定义:
int GetCheck( ) const;
返回值:
以BS_AUTOCHECKBOX, BS_AUTORADIOBUTTON, BS_AUTO3STATE, BS_CHECKBOX, BS_RADIOBUTTON, or BS_3STATE 风格创建的按钮控件,返回值为以下之一:
Value | Meaning |
0 | Button state is unchecked. 按钮处于未选中状态 |
1 | Button state is checked. 按钮处于选中状态 |
2 | Button state is indeterminate (applies only if the button has the BS_3STATE or BS_AUTO3STATE style). 按钮状态不定(仅当按钮风格为BS_3STATE或BS_AUTO3STATE时) |
If the button has any other style, the return value is 0.
如果按钮是其它风格,则返回0。
备注
Retrieves the check state of a radio button or check box.
本函数用于检测单选钮或复选框的选中状态。