1, in the existing project to add tab CONTR control
2. Add Variable to tab control M_tabctrl
3. Add the following code to the dialog initialization function OnInitDialog in the Cxxxdlg class:
Add Tab
M_tabctrl. InsertItem (0,_t ("Page 1"))//"tab 1" can be changed, is the name of the sheet page;
M_tabctrl. InsertItem (1,_t ("Page 2"));
M_tabctrl. InsertItem (2,_t ("Page 3"));
4, in the resource view of the Dialog, click the "Dialog" right button, select "Insert Dialog", insert three Dialog, id named Idd_dialog1, idd_dialog2, Idd_dialog3. In each dialog attribute, style is child, border is none, width is adjusted. Add the corresponding CDialog1 based on CDialog class separately, Cdialog2,cdialog3
5. Add the header files of the above three classes in CXXXDlg.h CDialog1.h CDialog2.h CDialog3.h
6, in CXXXDlg.h to add three member variables in turn m_para1, M_PARA2,M_PARA3, as follows:
CDialog1 m_para1;
CDIALOG2 M_para2;
CDialog3 M_para3;
Create a picture
m_para1. Create (Idd_dialog1, &m_tabctrl);
M_para2. Create (IDD_DIALOG2, &m_tabctrl);
7,//Get TabControl customer area size
CRect rs;
M_tabctrl. GetClientRect (&RS);
Adjust the position of the Child dialog box in the parent window to change the value so that the subform is the right size;
rs.top+=20;
rs.bottom-=3;
rs.left+=2;
rs.right-=2;
Sets the child dialog box dimensions and moves to the specified location
m_para1. MoveWindow (&RS);
M_para2. MoveWindow (&RS);
M_para3. MoveWindow (&RS);
Set the Hide and display
m_para1 separately. ShowWindow (true);
M_para2. ShowWindow (false);
M_para3. ShowWindow (false);
Set the default tab
M_tabmain.setcursel (0);
7. In the Resource View, double-click Tab control to add an event handler
TODO: Add control Notifications Handler code M_PARA1 here
. ShowWindow (false);
M_para2. ShowWindow (false);
M_para3. ShowWindow (false);
int cursel = M_tabmain.getcursel ();
Switch (Cursel)
{case
0:
m_para1. ShowWindow (true);
break;
Case 1:
m_para2. ShowWindow (true);
break;
Case 2:
m_para3. ShowWindow (true);
break; *presult = 0;
SOURCE Download: http://download.csdn.net/download/csdn1507/10115511