mfc控件 check box

来源:互联网 发布:谷歌浏览器for mac 编辑:程序博客网 时间:2024/04/25 20:59

在界面设计中,我们经常会用到Check Box这个控件,Check Box 的使用方法与Radio Button 的用法相似,但比它要简单得多。
一、设定Check Box为 选中状态
((CButton*)GetDlgItem(ID号))->SetCheck(TRUE);
(SetCheck(FALSE)) 为不选中,如果想初始化为选中状态,则在InitDlg函数中加入下面这段语句。
( (CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
二、检查Check Box是否为选中状态
可使用GetCheck()这个函数,如下:
if(BST_CHECKED==((CButton*)GetDlgItem(IDC_RADIO1))->GetCheck()) 判断是否选中;
if(BST_UNCHECKED==((CButton*)GetDlgItem(IDC_RADIO3))->GetCheck()) 判断是否未选中。
0 0