本文最主要的功能是选择不同的标签有不同的显示信息。
//头文件添加
CImageList m_ImageList;
CEmployee* m_eDlg;
CClient* m_cDlg;
CProvidedlg* m_pDlg;
CImageList m_ImageList;
CEmployee* m_eDlg;
CClient* m_cDlg;
CProvidedlg* m_pDlg;
BOOL CUseTabDlg::OnInitDialog()
{
// TODO: Add extra initialization here
m_ImageList.Create(24,24,ILC_COLOR24|ILC_MASK,1,0);
//向图像列表中添加图标
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
//将图像列表关联到标签控件中
m_Tab.SetImageList(&m_ImageList);
m_Tab.InsertItem(0,"员工信息",0);
m_Tab.InsertItem(1,"客户信息",1);
m_Tab.InsertItem(2,"供应商信息",2);
m_eDlg = new CEmployee;
m_cDlg = new CClient;
m_pDlg = new CProvidedlg;
m_eDlg->Create(IDD_DIALOG_EMP,&m_Tab);
m_cDlg->Create(IDD_DIALOG_CLI,&m_Tab);
m_pDlg->Create(IDD_DIALOG_PRO,&m_Tab);
m_eDlg->CenterWindow();
m_eDlg->ShowWindow(SW_SHOW);
return TRUE; // return TRUE unless you set the focus to a control
}
{
// TODO: Add extra initialization here
m_ImageList.Create(24,24,ILC_COLOR24|ILC_MASK,1,0);
//向图像列表中添加图标
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
//将图像列表关联到标签控件中
m_Tab.SetImageList(&m_ImageList);
m_Tab.InsertItem(0,"员工信息",0);
m_Tab.InsertItem(1,"客户信息",1);
m_Tab.InsertItem(2,"供应商信息",2);
m_eDlg = new CEmployee;
m_cDlg = new CClient;
m_pDlg = new CProvidedlg;
m_eDlg->Create(IDD_DIALOG_EMP,&m_Tab);
m_cDlg->Create(IDD_DIALOG_CLI,&m_Tab);
m_pDlg->Create(IDD_DIALOG_PRO,&m_Tab);
m_eDlg->CenterWindow();
m_eDlg->ShowWindow(SW_SHOW);
return TRUE; // return TRUE unless you set the focus to a control
}
void CUseTabDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int index = m_Tab.GetCurSel();
switch(index)
{
case 0:
m_eDlg->CenterWindow();
m_eDlg->ShowWindow(SW_SHOW);
m_cDlg->ShowWindow(SW_HIDE);
m_pDlg->ShowWindow(SW_HIDE);
break;
case 1:
m_cDlg->CenterWindow();
m_eDlg->ShowWindow(SW_HIDE);
m_cDlg->ShowWindow(SW_SHOW);
m_pDlg->ShowWindow(SW_HIDE);
break;
case 2:
m_pDlg->CenterWindow();
m_eDlg->ShowWindow(SW_HIDE);
m_cDlg->ShowWindow(SW_HIDE);
m_pDlg->ShowWindow(SW_SHOW);
break;
}
*pResult = 0;
}
{
// TODO: Add your control notification handler code here
int index = m_Tab.GetCurSel();
switch(index)
{
case 0:
m_eDlg->CenterWindow();
m_eDlg->ShowWindow(SW_SHOW);
m_cDlg->ShowWindow(SW_HIDE);
m_pDlg->ShowWindow(SW_HIDE);
break;
case 1:
m_cDlg->CenterWindow();
m_eDlg->ShowWindow(SW_HIDE);
m_cDlg->ShowWindow(SW_SHOW);
m_pDlg->ShowWindow(SW_HIDE);
break;
case 2:
m_pDlg->CenterWindow();
m_eDlg->ShowWindow(SW_HIDE);
m_cDlg->ShowWindow(SW_HIDE);
m_pDlg->ShowWindow(SW_SHOW);
break;
}
*pResult = 0;
}
void CUseTabDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
m_eDlg->DestroyWindow();
delete m_eDlg;
m_cDlg->DestroyWindow();
delete m_cDlg;
m_pDlg->DestroyWindow();
delete m_pDlg;
CDialog::OnClose();
}
{
// TODO: Add your message handler code here and/or call default
m_eDlg->DestroyWindow();
delete m_eDlg;
m_cDlg->DestroyWindow();
delete m_cDlg;
m_pDlg->DestroyWindow();
delete m_pDlg;
CDialog::OnClose();
}