• 9
• 9
• 10
• 9
• 10

# MFC - Tab Control

This topic is 4707 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi, i made my dialogs and built their classes.. etc. and now i want to put them in a tab control. i made another dialog for this and added a tab object. but i could not find correct functions to add a page for the tab that is in the new dialog window. that works:
CPropertySheet sheet("Controls");

CPropertyPage page1(IDD_PROP_1), page2(IDD_PROP_2),
page3(IDD_PROP_3), page4(IDD_PROP_4);

sheet.EnableStackedTabs(FALSE);
sheet.DoModal();

but i could not use it in CSplitterWnd. i mean it makes a window alone, not in the editors split. so do i have to use runtime class? not CPropertySheet? Thank You!

up. o_0

##### Share on other sites
If you want your tab to be modeless (inside a view for example) you need to call Create instead of DoModal.

Don't forget to set the correct parent CWnd!

##### Share on other sites
i want to make it in CSplitterWnd. so how can i get the window pointers for row and columns?
i am filling the cell like this:
MainSplitter.CreateView( 0, 1, RUNTIME_CLASS(CPanels),  //CPanels is the dialog class with tabctrl		CSize( cr.Width() - PANEL_WIDTH, cr.Height() ), pContext )

i want to use my tabs in a runtime class, but i could not add my pages to a tab control that is in a dialog.

question in another form: how can i add my pages to IDD_PANELS's IDC_TAB ???

thanks..

##### Share on other sites
Inside the CPanels OnCreate function you could add the tabs.

Other, not so nice possibility: With GetPane you can get one of the splitters panes, but you only get the CWnd.
You can cast the CWnd of your panel to CPanel and then add the pages there.

There is no way to add the pages in the resources. The CPropertySheet class has some additional code to provide child dialog switching for you, which the pure TabCtrl can't do.

##### Share on other sites
Quote:
 Original post by EndurionInside the CPanels OnCreate function you could add the tabs.
i see, but which function will i use for adding pages to IDC_TAB? i am looking for it for days... thx.

##### Share on other sites

Let the wizard add a class for your Tab Control. Make it a CPropertySheet instead of CDialog.
Derive your pages from CPropertyPage instead of CDialog and you can use AddPage from the CPropertySheet class.

There is no Win32 equivalent. On a pure Tab Control you can only insert "empty" items (just a tab with a name, no content). You will have to listen for a TCN_SELCHANGE notification message in WM_NOTIFY and remove/insert the dialogs yourself.

##### Share on other sites
i make the runtime class and add the tab and pages to it with a tutorial @codesampler. it seems same with the tutorial and works ok alone. but when i call MainSplitter.CreateView() function to put that panel class to the cell it returns error?
i was using a CFormView class for splitter, cannot it be a CDialog or a CPropertySheet class? (i tried with CPropertySheet too, it gives same error, now i am going to try with CFormView i dont think it is going to work.. or is the problem @somewhere else? hmm.. )

i think i am going to change the program's interface and make buttons for tabs.. :(

do you know any simple open source project using a technique like this ???
thank you!..