Creating Tabbed Dialogs Using MFC

How do I create a tabbed dialog in MFC that has the look and feel of the ones you find in Windows 95?
I have posted messages for this question and have never really gotten an answer, most books I have seen tell you how to create the tabbed dialogs with an SDI. But that is not what I want, I want just the tabbed window when the program is executed.

i.e. right click on the windows 95 desktop and select properties

The following lines is what I came up with while the entire web, it does not do me any good cause parts are missing.  Since I dont have much experience in Visual C++ this is a project I really want to accomplish, but I dont know how.

Creating Property Pages

(1) do I create a dialog based application first ????

1.In the Microsoft Developer Studio, select the Resource View tab.
2.Right Click on the Dialog folder.
3.Select the Insert Dialog menu option from the popup menu.
4.You should now have a new dialog resource with a default name like IDD_DIALOG1. Feel free to rename it to a more meaningful name. You may also want to remove the OK and Cancel buttons being that this will be a tab in a dialog which will contain that functionality outside of the tabs. Next, you could add all the controls (radio buttons, listboxes, etc.) that you want to appear on that tab. Also, the dialog caption becomes the tab caption, so it is a good idea to change the caption at this point to the name that you want to appear in the tab.

what about the properties for the dialog box (child, thin etc)

5.Use the Class Wizard to generate your CPropertyPage derived class that incorporates your new dialog resource. If you invoke Class Wizard while the focus is on a new dialog resource, Class Wizard will assume your intention is to create a new class for this resource, and will prompt you. If that is the case click on the OK button and follow the remaining steps in Class Wizard to generate your class. Most importantly, do not forget to change the Base Class to CPropertyPage in the Class information frame.

Creating a Property Sheet

1.Use the Class Wizard to generate a new CPropertySheet derived class. When the "Create New Class" dialog appears ensure that the Base Class you select is CPropertySheet.
2.Click the "Create" button and your new Property Sheet class will be created.

Putting it all together

Up until this point you have managed to practically create a tabbed dialog without writing a single line of code by making use of the Resource Editor and the Class Wizard; however, this is where the Wizards stop on this journey. Now the programmer must finish the job. To successfully display a multi-tabbed dialog, you should:

Include all CPropertyPage derived object variables as data members of your CPropertySheet derived classed.

 // KingDlg.h : header file
 #include proppage1.h
 #include proppage2.h
 #include proppage3.h
 class CKingDlg : public CPropertySheet  {
 // Construction
        CKingDlg(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);       ...
 // The objects vars for pages/tabs in KingDlg  public:
        CPropPage1 m_page1;
        CPropPage2 m_page2;
        CPropPage3 m_page3;

After constructing the CPropertyPage object variables [which will happen automatically if they are defined as objects as opposed to pointers to objects], call CPropertySheet::AddPage(CPropertyPage* pPage) for each object variable in the constructor of CPropertySheet.

// KingDlg.cpp : implementation file

#include "stdafx.h"
#include "tabs.h"
#include "KingDlg.h"


CKingDlg::CKingDlg(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
        :CPropertySheet(nIDCaption, pParentWnd, iSelectPage) {

Finally elsewhere in your code you may declare a variable of type CKingDlg that will display results of your creation upon a call to DoModal or Create. For instance:


CKingDlg kingDlg;

kingDlg.DoModal(); // multi-tab dialog appears!!!

The above has a lot of missing areas, I would really like a step by step solution on how to do this.  I asked a few people who do Visual C++ and they did not know how to create the tabbed dialogs.

Any help is greatly appreciated.

Thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The easiest way to understand what you want is adding "Property Sheet" component from "Component Gallery".
I don't know if you want to create a Tab Dialog or a Property Page? I mean with or without the OK, Cancel and Apply buttons? Anyway. To create a property sheet is a fairly simple task with VC++. You want to create a dialog based app with a tab sheet inside. Right? Here is what you will have to do:
1. Create as many dialog as you like (will be the tabs). Their captions will be the text you will see in the tab controls.
2. Create for each dialog resource you just added a derived class from CPropertyPage (put all into the same file).
3. Create a new class derived from CPropertySheet (put into the same file).
4. Put into the definition of the CPropertySheet class data members for each PropertyPage. Declare them as private. (for example "CPage1 m_page1;")
5. Add to the constructor of the propertysheet class (the one with the LPCTSTR variable) the AddPage(&m_page) command for each propertypage.

This was the procedure for the property sheet. Now here is what to do to show the dialog:
1. Remove the pre created dialog class. and the pre created dialog resource. delete the corresponding file.
2. remove the include declaration from the main app file.
3. include the propertysheet header file.
4. in initinstance remove the pre generated dialog class declaration and replace it with the property sheet class declaration:
CMyAppDlg dlg;
 m_pMainWnd = &dlg;
 int nResponse = dlg.DoModal();


CTab dlg("My caption");
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();

Ok, that should be all. Hope I forgot nothing.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
theadmin090797Author Commented:
This is really a cool example but there are too many things in between thats missing.  Can someone explain this to a person who does not know Visual C++ very well, lets say you are giving someone directions on the phone how will you explain it to them step by step.  This is what I am trying to get here.
theadmin090797Author Commented:
This is really a cool example but there are too many things in between thats missing.  Can someone explain this to a person who does not know Visual C++ very well, lets say you are giving someone directions on the phone how will you explain it to them step by step.  This is what I am trying to get here.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.