Tab Control and Multiple Dialogs

I have a resource called MainDlg described by CMainDlg class and also Dlg1, Dlg2, Dlg3 resources described by CDlg1, CDlg2, CDlg3 classes, accordingly.

On MainDlg I placed a Tab Control which I then (in the program) initialized with 3 tabs that are supposed to display the three secondary dialogs.

The question is: what code in the function processing the Tab Control left-click message (or whatever) I should use if I want to build something like the Property Pages without directly using the CPropertyPage (or however it is called)?

In other words, how can I link a tab from the tab control with a child window to display? Or should I use a different method altogether?

The reason I don't want to use the predefined class of Property Pages is that it doesn't allow to manage the buttons (Ok, Cancel, Apply, Help) on its bottom, and I don't need them there.
Who is Participating?
RONSLOWConnect With a Mentor Commented:
Use child dialogs and

Look at the MS KB article and sample

SAMPLE: Property Sheet as the View Window of a CFrameWnd
ID: Q161886

Despite the title, it shows how to use your own tab control and child dialogs (rather than use CPropertySheet).

The SDK documenation has a section on "Tab Control" where it also shows code for how to create a tab control with child dialogs etc.

Property pages do let you control the buttons at the bottom.  For example, you can turn them on or off, movethem around, add other ones etc.

if you still don't wnat to use them and prefer to roll-your-own instead, respond to:


within the handler do something like
  int tabselected = m_xxx.GetCurSel();
where m_xxx is a CTabCtrl you've associated with the tab control (or you can use GetDlgItem if you prefer).

LeschaAuthor Commented:
No, no, I know _how_ to respond to the clicks. What I am asking is how do I display a different bunch of controls for every page?

Do I have to create them during the run-time? If so, they must have predefined classes. Not good. If not, how can I use a predefined dialog?
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

LeschaAuthor Commented:
Oh, drat! You mean, there is no control in MFC parallel to PageControl in Delphi? And all other derivatives from the idea of the tabs? Niet? :-(
This is not MFC so much, as windows.

A tab control is simply a control that has some tabs and for which you can handle clicks.  It is very much like a set of radio buttons in that respect.

The smarts are in how you respond to the clicks on tabs.  It could just change the way some control display data, or make some control appear/disappear, or display child dialogs etc.  It is all up to the programmer.

Windows does provide a property page / sheet that uses a tab-control.  You can embedd that within a dialog and it will manage the pages and child dialogs etc.  When you embed it in another dialog, you don't get the OK/Cancel buttons etc.  You can provide your own ones.

That is probably closest to the page control thing you talk about in Delphi (never seen it so I can only guess).  And would be the best solution (I think) for your problem.  I can point you to sample code that shows how to do this, if you like.

LeschaAuthor Commented:
Yes, I'd appreciate that. I tried the PropertyPage before, but as a stand-alone resourse, and couldn't get rid of the annoying buttons.
best place is to go to

Property Sheet + Property Page will have the buttons unless you make it modeless or put it in a dialog as a child.

There are plenty of examples at the codeguru site that will show you a lot of possible solutions.  Pick the one that you unserstand the best and best suits your requirements.
LeschaAuthor Commented:
Thanks, I'll take a look. I knew about that site, but never took time to dug deeply.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.