Newbie question on tab controls
I'm developing an MDI app in MFC and I want to add tabs along the top of the child windows (I havent changed the child windows themselves since the AppWizard set them up). I have got as far as drawing a tab control in the resource editor, the tabs are named tab1 - tab5. When compiling the tabs arent there, there is just a big 3d box where they should be, and how do I select the tabs from within VC++6 to change what is in each one.
I've looked through Petzold and some websites but everywhere seems to assume you can physically draw the controls in the resource editor, I cant work it out :(.
Help appreciated
tab controls embedded in Form
I found the tab control quite confusing so this is what I did instead. I created separate dialog templates...one for each tab in my control. Then I created them from the OnInitialUpdate() virtual function of CMyFormView... the code goes something like this...
in the MyFormView.h header declare the variables
CMyPage1 m_Page1;
CMyPage2 m_Page2;;
CMyPage3 m_Page3;
CPropertySheet* pSheet;
[CODE]
void CMyFormView::OnInitialUpdate()
{
...this call should really be made from the OnCreate message handler
....
CreateTabControl();
}
void CMyFormView::CreateTabControl()
{
pPropertySheet = new CPropertySheet( "My Tab", this, 0);
pPropertySheet->AddPage( &m_Page1 );
pPropertySheet->AddPage( &m_Page2 );
pPropertySheet->AddPage( &m_Page3 );
pPropertySheet->Create( this, WS_CHILD | WS_VISIBLE );
//** Create a static text with the resource editor where you
//** would like to position your control and bind a CStatic
//** member to it... you must change the default idd from
//** IDC_STATIC to IDC_STATIC1 or something more meaningfull
CRect r;
m_staticPlaceHolder.GetWindowRect( &r );
ScreenToClient( &r );
//** reposition the window where you want it.....
pPropertySheet->SetWindowPos( pPropertySheet,
NULL, r.top, r.left, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
}
CODE]
Remember that the page members must be your own classes derived from the CPropertyPage class... to create them with the correct property settings from the resource editor insert new resource ... select DIALOG... then IDD_PROPERTYPAGE_MEDIUM.. you can always resize it... then from the class wizard create the class as you normally would for a dialog but remember to change the base class to CPropertyPage instead of CDialog.... this will add all the necessary code to get you started... and a very important point to remember is that you cannot access the property pages except for the one selected by default until they have been selected by the user or you have set the focus on the through the property sheet member SetActivePage(...)
I hope this helps... I found this much easier to implement than the tab control.....