1.时间控件的应用:
时间控件关联的变量为m_date(类型为CTime),添加strdate(类型为CString),调用strtime = m_date.Format("%Y-%m-%d");就可以得到想要年月日字符串。
2.ComboBox控件的应用:
ComboBox关联变量为m_sex(类型为CComboBox),添加变量m_tempSex(类型为CString),调用m_sex.GetLBText(m_sex.GetCurSel(),m_tempSex);
就可以得到选中的文本。
3.标签控件的应用:
添加一个新的对话框,向其中添加一个标签控件,标签页关联一个变量m_tab(类型为CTabCtrl),添加此对话框关联的类CTab。
向此类添加几个类对象:
CYuanGgXinXi m_YuanGnXinXi;CQiTaGnZi m_QiTaGnZi;CKaoQin m_KaoQin;CJiBenGnZi m_JiBenGnZi;CBuMen m_BuMen;
当然不要忘记在头文件中添加这些类的头文件。
#include "BuMen.h" // Added by ClassView#include "JiBenGnZi.h" // Added by ClassView#include "KaoQin.h" // Added by ClassView#include "QiTaGnZi.h" // Added by ClassView#include "YuanGgXinXi.h" // Added by ClassView
添加成员函数:
BOOL CTab::OnInitDialog(){ CDialog::OnInitDialog(); m_tab.InsertItem(0,"员工信息表",0);//向标签控件中添加标签页 m_tab.InsertItem(1,"部门信息",1); m_tab.InsertItem(2,"考勤表",2); m_tab.InsertItem(3,"其他工资表",3); m_tab.InsertItem(4,"月度工资统计表",4); m_YuanGnXinXi.Create(IDD_YUAN_GONG_XIN_XI,&m_tab);//创建子窗口 m_BuMen.Create(IDD_BU_MEN_XIN_XI,&m_tab); m_KaoQin.Create(IDD_KAO_CHENG_XIN_XI,&m_tab); m_QiTaGnZi.Create(IDD_QI_TA_GONG_ZI_XIN_XI,&m_tab); m_JiBenGnZi.Create(IDD_JI_BEN_GONG_ZI,&m_tab); CRect clientRC; m_tab.GetClientRect(clientRC); //获取标签客户区域 clientRC.DeflateRect(20,30,20,20); //减小客户区域的大小。 m_YuanGnXinXi.MoveWindow(clientRC); //移动子窗口 m_BuMen.MoveWindow(clientRC); m_KaoQin.MoveWindow(clientRC); m_QiTaGnZi.MoveWindow(clientRC); m_JiBenGnZi.MoveWindow(clientRC); m_BuMen.ShowWindow(SW_SHOW); //显示子窗口 m_tab.SetCurSel(1); //设置默认选中的窗口 return TRUE;}void CTab::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here int nCurSel = m_tab.GetCurSel(); //获取当前选中标签页索引 CRect clientRC; m_tab.GetClientRect(clientRC); clientRC.DeflateRect(20,30,20,20); if(nCurSel == 0) //如果第一个标签页被选中 { m_YuanGnXinXi.ShowWindow(SW_SHOW); //显示选中的对话框 m_BuMen.ShowWindow(SW_HIDE); //隐藏子对话框 m_KaoQin.ShowWindow(SW_HIDE); m_QiTaGnZi.ShowWindow(SW_HIDE); m_JiBenGnZi.ShowWindow(SW_HIDE); } else if(nCurSel == 1) { m_YuanGnXinXi.ShowWindow(SW_HIDE); m_BuMen.ShowWindow(SW_SHOW); m_KaoQin.ShowWindow(SW_HIDE); m_QiTaGnZi.ShowWindow(SW_HIDE); m_JiBenGnZi.ShowWindow(SW_HIDE); } else if(nCurSel == 2) { m_YuanGnXinXi.ShowWindow(SW_HIDE); m_BuMen.ShowWindow(SW_HIDE); m_KaoQin.ShowWindow(SW_SHOW); m_QiTaGnZi.ShowWindow(SW_HIDE); m_JiBenGnZi.ShowWindow(SW_HIDE); } else if(nCurSel == 3) { m_YuanGnXinXi.ShowWindow(SW_HIDE); m_BuMen.ShowWindow(SW_HIDE); m_KaoQin.ShowWindow(SW_HIDE); m_QiTaGnZi.ShowWindow(SW_SHOW); m_JiBenGnZi.ShowWindow(SW_HIDE); } else { m_YuanGnXinXi.ShowWindow(SW_HIDE); m_BuMen.ShowWindow(SW_HIDE); m_KaoQin.ShowWindow(SW_HIDE); m_QiTaGnZi.ShowWindow(SW_HIDE); m_JiBenGnZi.ShowWindow(SW_SHOW); } *pResult = 0;}