This article describes a simple example of adding a label to a normal dialog box.
In the first step, drag a tab control to the dialog box and add the variable m_tabctrl;
Step 2: Add two dialog boxes: Resource idd_dialog1, idd_dialog2, set style to child, border to none, and add corresponding cdialog m_page1, m_page2
Step 3 Add the following code in oninitdialog ()
Code
// Add a tab name
M_tabctl.insertitem (0, l "Tab 1 ");
M_tabctl.insertitem (1, l "Tab 2 ");
// Set idc_tab1 as the parent window
M_page1.create (idd_dialog1, getdlgitem (idc_tab1 ));
M_page2.create (idd_dialog2, getdlgitem (idc_tab1 ));
// Obtain the size of the idc_tabtest client Zone
Crect RC;
M_tabctl.getclientrect (& rc );
// Adjust the position of the subdialog box in the parent window
RC. Top + = 30;
RC. Bottom-= 8;
RC. Left + = 8;
RC. Right-= 8;
// Set the size of the subdialog box and move it to the specified position
M_page1.movewindow (& rc );
M_page2.movewindow (& rc );
// Hide and display
M_page1.showwindow (true );
M_page2.showwindow (false );
// Set the default Tab
M_tabctl.setcursel (0 );
Step 4 Add the tcn_selchange Event Response Function onselchangetabtest (nmhdr * pnmhdr, lresult * presult) of the tab control. The function body code is as follows:
Code
Void cpropagedlg: ontcnselchangetab1 (nmhdr * pnmhdr, lresult * presult)
{
// Todo: add the control notification handler generation here
Int cursel = m_tabctl.getcursel ();
Switch (cursel)
{
Case 0:
M_page1.showwindow (true );
M_page2.showwindow (false );
Break;
Case 1:
M_page1.showwindow (false );
M_page2.showwindow (true );
Break;
}
* Presult = 0;
}
Then adjust the appropriate position of the dialog box ....