VC++6.0MFC常用控件.docx
文本预览下载声明
一般控件可用/不可用
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.
Return Value
ID of the checked radio button, or 0 if none is selected.
?
(4)控件变量类型为Value时,可通过给int型变量赋值0、1、2...选中第1、2、3...个选项。
int型变量默认值为-1,是在构造函数中赋的值。
当然也可通过判断int型变量的值,知道哪一个选项被选中。
?
5、Combo Box-----------组合框控件?--类CComboBox
(1)风格
Simple-象List Box一样显示数据
Dropdown-可以输入,也可以选择
Drop List-只能选择
(2)添加数据
a.属性对话框-Data-Enter listbox items,用Ctrl+Enter换行;
b.m_combo.AddString(string);
c.m_combo.InsertString(index,string);
(3)显示数据
设计页面,点击Combo Box Control右边的下拉箭头,显示的矩形框就是显示数据的区域。
(4)设置当前选项
m_combo.SetCurSel(项索引);
(5)获取当前选项
int nIndex = m_combo.GetCurSel();
CString str;
m_
显示全部