1, define a CTabCtrl in the main window, add the variable M_tabctrl;
2. Add two sub-Windows Idd_one_dialog,idd_two_dialog with child and no border
3. Define the class object of these two child windows in the main window header file M_one,m_two
Customize the following function, put in the initialization function, give the tab generated two interface
void Cdlg::addtab ()
{
CRect rect;
This->getclientrect (&rect);
M_tabctrl. InsertItem (0, _t ("1"));
M_tabctrl. InsertItem (1, _t ("2"));
M_server. Create (Idd_one_dialog, &m_tabctrl);
M_server. SetWindowPos (NULL, 0, +, rect). Width (), Rect. Height (), Swp_showwindow);
M_client. Create (Idd_two_dialog, &m_tabctrl);
M_client. SetWindowPos (NULL, 0, +, rect). Width (), Rect. Height (), Swp_hidewindow);
}
4, rewrite Ontcnselchangetab (NMHDR *pnmhdr, LRESULT *presult) virtual function
Show or hide the corresponding item by following
Switch (M_tabctrl. GetCurSel ())
{
Case 0:
{
M_server. SetWindowPos (NULL, 0, +, rect). Width (), Rect. Height (), Swp_showwindow);
M_client. SetWindowPos (NULL, 0, +, rect). Width (), Rect. Height (), Swp_hidewindow);
Break
}
Case 1:
{
M_server. SetWindowPos (NULL, 0, +, rect). Width (), Rect. Height (), Swp_hidewindow);
M_client. SetWindowPos (NULL, 0, +, rect). Width (), Rect. Height (), Swp_showwindow);
Break
}
Use of CTabCtrl