本文中所用控件变量类型为Control
一般控件可用/不可用
EnableWindow(TRUE);
EnableWindow(FALSE);
1、Static Text------------静态控件--类CStatic
取值/赋值(变量类型为Control)
m_lbl.GetWindowText(string);
m_lbl.SetWindowText(string);
2、Edit Box---------------编辑控件--类CEdit
取值/赋值
m_txt.GetWindowText(string);
m_txt.SetWindowText(string);
3、Check Box------------复选控件--类CButton
(1)设置选中/未选中
m_chk.SetCheck(BST_CHECKED);
m_chk.SetCheck(BST_UNCHECKED);
(2)判断是否选中
int nCur = m_chk.GetCheck();
nCur取值为BST_CHECKED/BST_UNCHECKED。
4、Radio Box------------单选控件--类CButton
(1)默认选中第一项
m_radio.SetCheck(BST_CHECKED);
(2)选中组中任一项
CWnd::CheckRadioButton
Selects (adds a check mark to)a given radio button in a group and clears (removes a check mark from)all other radio buttons in the group.
void CheckRadioButton(int nIDFirstButton, int nIDLastButton, int nIDCheckButton );
Parameters
nIDFirstButton
Specifies the integer identifier of the first radio button in the group.
nIDLastButton
Specifies the integer identifier of the last radio button in the group.
nIDCheckButton
Specifies the integer identifier of the radio button to be checked.
(3)判断哪一项被选中
CWnd::GetCheckedRadioButton
Retrieves the ID of the currently checked radio button in the specified group.
int GetCheckedRadioButton(int nIDFirstButton, int nIDLastButton );
Parameters
nIDFirstButton
Specifies the integer identifier of the first radio button in the group.
nIDLastButton
Specifies the integer identifier of the last radio button in the group.