Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


MFC People where are you at?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

MFC people I just wanted to know if you knew how to get Tabs to work. I went to codeguru.com and codeproject.com but they didn''t have very good tutorials on how to get tabs to work for begginers. If you don''t know the answer downlaod the source and tell me what you think about the program. I think I''ll make a tut on it if I can ever figure out tabs. STARVIEWMFC

Share this post

Link to post
Share on other sites
As Keanu Reaves(sp) would say...woooh..

Tabs in MFC are tricky. You may want
to check out CTabCtrl at MSDN.
I looked into them earlier. I remember
having to make dialogs for each of the pages
I wanted to add to them. Then I read
to add them manually. I never
got around to trying it out since
it was easier to make a wrapper in VB.
Please post if you find a good resource!

Share this post

Link to post
Share on other sites
Yeah for what it''s worth, I also looked into them and came to the same conclusions as Taulin. They are a pain in the neck
You have to make one dialog for each tab and combine them all in code.

Its one of those things (there seem to be way too many) that ought to be really easy to do, but isn''t.

That''s my experience anyway.


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Easy solution is to use FOX. It''s better than MFC and supports multiple platforms too. Using Tabs as wells as other widgets are a piece of cake.


Share this post

Link to post
Share on other sites
Ahhhhhhh tab controls, yes un fun. easy in VB (go figure) and a pain in MFC. I would keep checking on Codeguru.com. I found my examples there. A loose explanation on the one i found is this:

Draw your tab control onto the dialog. Then what you have to do is create seperate dialogs to place upon the dialog (these seperate dialogs will be shown or hidden depending upon which tab is selected).

So then in your main dialog, u have to set up those other dialogs to be displayed in your main dialog (the one with the actual tab control). Here is an example:
First underneath the last include as global we need this:
(inside your main dialog.cpp the one with the tab control on it.)
#include "DlgFirst.h"
#include "DlgSecond.h"
#include "DlgThird.h"

//Instantiate your other dialog classes to here.
DlgFirst dlg_MyFirstDialog;
DlgSecond dlg_MyFirstDialog; //DlgSecond, is the name of your
//second dialog class you made.
DlgThird dlg_MyFirstDialog;

BOOL DlgMain::Create(CWnd*pParent, LPCSTR lpszTitle)
//fill out top tab lables
//note the IDC_TAB1 its the id of your tab control
CTabCtrl *tabMain = (CTabCtrl *) GetDlgItem(IDC_TAB1);
tabMain->InsertItem(0, _T("My Tab 1"));
tabMain->InsertItem(1, _T("My Tab 2"));
tabMain->InsertItem(2, _T("My Tab 3"));
//Select our tabs to start
LoadCurrentSel(); //we will return to this.

//this is important function, it gets the user clicks
//figures out what tab it was on and then displays the appropiate

void DlgMain::LoadCurrentSel(LPNMHDR *hdr, LPARAM *NotUsed)
// Get current selection
CTabCtrl *tabMain = (CTabCtrl *) GetDlgItem(IDC_TAB1); //not the IDC TAB1 again
int nCurSel = tabMain->GetCurSel();
// Load corresponding child
case 0:
// Show child 1
case 1:
// Show child 2
case 2:
// Show child 3


then down furhter still in your main dialog.cpp (the dialog with the tab control on it)
you will see:

BEGIN_MESSAGE_MAP(DlgMain, CAcUiDockControlBar)
ON_WM_CREATE()//should already be there
///need to add this:makes sure we call LoadCurrentSel
//when windows gets the TCN_SELCHANGE message.

Then in that main dialog .h the public part of your class u need this:

void LoadCurrentSel(LPNMHDR *hdr = NULL, LPARAM *NotUsed = NULL);

As for the Dialogs you want (basically whats on each tab is a seperate dialog that ive coined above to be DlgFirst, DlgSecond etc..)
These dialogs need to have the following prorperties:

In styles tab of properties make sure the style is:
Border is None
and everythign else in every other styles tab is NOT checked.

Then the cool thing is each "tab" you have info on is a matter of editing and adding controls to the dialog that represents a tab so it should be pretty straight forward. I hope this helps. If not, please email me and maybe I can work with ya on this.

p.s. email is: Codejoy@yahoo.com

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!