标签:
转载至 http://blog.csdn.net/jacklam200/archive/2008/08/01/2753797.aspx
一、在对话框视图中加入CTabCtrl控件
资源ID:IDC_TAB,变量名:m_Tab
二、在OnInitDialog()中加入以下代码:
m_Tab.InsertItem(0,"窗口1");
m_Tab.InsertItem(1,"窗口2");
// 创建子窗口实例(事先创建好),将父窗口设为m_Tab
// CChileDlg1 m_dlgChile1;
// CChileDlg2 m_dlgChile2;
m_dlgChile1.Create(IDD_DIALOG_CHILD1,GetDlgItem(IDC_TAB));
m_dlgChile2.Create(IDD_DIALOG_CHILD2,GetDlgItem(IDC_TAB));
// 将子窗口显示在m_Tab范围内
CRect rs;
m_Tab.GetClientRect(rs);
rs.top+=20;
rs.bottom-=4;
rs.left+=4;
rs.right-=4;
m_dlgChile1.MoveWindow(rs);
m_dlgChile2.MoveWindow(rs);
// 默认显示第一个子窗口
m_Tab.SetCurSel(0);
m_dlgChile1.ShowWindow(TRUE);
示例代码
view plaincopy to clipboardprint?
Item.mask = TCIF_TEXT;
int nPages = 2; //3个页面
for(int nN = 0; nN < nPages; nN++)
{
switch(nN)
{
case 0:
m_zipDlg.Create(IDD_ZIP,GetDlgItem(IDC_TAB1));
break;
case 1:
m_unZipDlg.Create(IDD_UNZIP,GetDlgItem(IDC_TAB1));
break;
}
}
for(int nN = 0; nN < nPages; nN++)
{
switch(nN)
{
case 0:
Item.pszText=_T("ZIP");
break;
case 1:
Item.pszText=_T("UNZIP");
break;
}
m_tab.InsertItem(nN,&Item);
}
m_tab.SetCurSel(0);
m_zipDlg.ShowWindow(TRUE);
Item.mask = TCIF_TEXT;
int nPages = 2; //3个页面
for(int nN = 0; nN < nPages; nN++)
{
switch(nN)
{
case 0:
m_zipDlg.Create(IDD_ZIP,GetDlgItem(IDC_TAB1));
break;
case 1:
m_unZipDlg.Create(IDD_UNZIP,GetDlgItem(IDC_TAB1));
break;
}
}
for(int nN = 0; nN < nPages; nN++)
{
switch(nN)
{
case 0:
Item.pszText=_T("ZIP");
break;
case 1:
Item.pszText=_T("UNZIP");
break;
}
m_tab.InsertItem(nN,&Item);
}
m_tab.SetCurSel(0);
m_zipDlg.ShowWindow(TRUE);
三、响应m_Tab的TCN_SELCHANGE消息,实现切换页面功能
void CMyDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
int nCurSel = m_Tab.GetCurSel();
switch(nCurSel)
{
case 0: // 显示子窗口1
m_dlgChile1.ShowWindow(TRUE);
m_dlgChile2.ShowWindow(FALSE);
break;
case 1: // 显示子窗口2
m_dlgChile1.ShowWindow(FALSE);
m_dlgChile2.ShowWindow(TRUE);
break;
}
*pResult = 0;
}
------------------------------------------------------------------------------------------------------
windows mobile的
PROPSHEETHEADER psh;
PROPSHEETPAGE psp[2];
int i = 0;
memset(&psh, 0, sizeof(PROPSHEETHEADER));
for(i = 0; i < 2; i++)
{
psp[i].dwSize = sizeof(PROPSHEETPAGE);
psp[i].dwFlags = PSP_DEFAULT | PSP_USETITLE;
psp[i].hInstance = g_hInst;
psp[i].lParam = (LPARAM)hWnd;
}
psp[0].pszTitle = TEXT("压缩文件");
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_ZIPFILE);
psp[0].pfnDlgProc = (DLGPROC)ZipDlgProc;
psp[1].pszTitle = TEXT("解压文件");
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_UNZIP);
psp[1].pfnDlgProc = (DLGPROC)UnzipDlgProc;
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_MAXIMIZE;
psh.hwndParent = hWnd;
psh.hInstance = g_hInst;
//psh.pszCaption = TEXT("Prop Sheet Title");
psh.nPages = 2;
psh.nStartPage = 0;
psh.ppsp = psp;
psh.pfnCallback = 0;
i = PropertySheet(&psh);
标签:
原文地址:http://www.cnblogs.com/jshchg/p/4427536.html