Click here to Skip to main content
11,717,883 members (78,985 online)
Click here to Skip to main content

Simple Tab Control For Visual C++

, 14 Oct 2004 202.9K 9K 57
Rate this:
Please Sign up or sign in to vote.
Using this Tab control the user can manage their dialogs in different Tab panes.

Introduction

This is my first article for the CodeProject, so please excuse me if it is really hard to understand. But I am always ready to help you on this.

Using this simple Tab control you can manage your panes separately. The most interesting thing is that you do not need to concentrate separately on your Tab control. Create your tab windows as normal dialog boxes, then you can link those dialogs to the Tab control by simply using the code given below. Set your dialog properties as follows: (dialogs to be displayed as tab panes)

  • Border: None
  • Title Bar: False
  • System Menu: False
  • Style: Popup

The client edge and other edge styles can be set according to your needs. Those edge styles will be a reflection of your tab pane.

// In your main dialog (where your Tab Control is) in OnInitDialog 
// write these simple lines to add your dialogs to Tab Panes.
   p1 = new CTabPageOne(); //p1 is a pointer to CTabPageOne (Dialog Box) 
   p1->Create(IDD_DIALOG_PAGE1,m_ctrlTAB.GetWindow(IDD_DIALOG_PAGE1));
   p2 = new CTabPageTwo(); //p1 is a pointer to CTabPageOne (Dialog Box) 
   p2->Create(IDD_DIALOG_PAGE2,m_ctrlTAB.GetWindow(IDD_DIALOG_PAGE2));

Add the above dialog boxes to your Tab control. Your Tab control is created from CibTabCtrl.

m_ctrlTAB.AddTabPane("Tab Intro",p1);
m_ctrlTAB.AddTabPane("My Tab Pages",p2);

There are two more things to do. That is, add the OnMove event to your main dialog box using your class wizard:

void CTabDlg::OnMove(int x, int y)
{
    m_ctrlTAB.OnMove(x,y);
}

Now, add the OnShowWindow event to your main dialog box using your class wizard.

void CTabDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
    CDialog::OnShowWindow(bShow, nStatus); 
    m_ctrlTAB.SetDefaultPane(1);
}

Foooo... That's all you have to do. Now you can run and see your output. Hope it works for you!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

venura c.p.w. goonatillake
Software Developer (Senior)
Sri Lanka Sri Lanka
I am working as a Tech Lead. I love VC++.
I am trying to get into new technologies coming with VC++ and also in other areas too.

Currently I am working in C# .Net as well...

Now I have sound knowledge in C# as well as in VC++.

You may also be interested in...

Comments and Discussions

 
Questionmicrosoft (R) developer studio has stopped working. Pin
Mạnh Lê3-Mar-14 20:09
memberMạnh Lê3-Mar-14 20:09 
QuestionError IDD_DIALOG_PAGE1 & IDD_DIALOG_PAGE2: undeclared identifier Pin
tag_question19-Dec-12 16:48
membertag_question19-Dec-12 16:48 
AnswerRe: Error IDD_DIALOG_PAGE1 & IDD_DIALOG_PAGE2: undeclared identifier Pin
tag_question19-Dec-12 17:07
membertag_question19-Dec-12 17:07 
GeneralMy vote of 3 Pin
buyong24-Oct-11 16:51
memberbuyong24-Oct-11 16:51 
QuestionUse NTGraph as a resizeable control in the CTabCtrl-class object Pin
Member 789153519-Sep-11 17:56
memberMember 789153519-Sep-11 17:56 
Questionexe file Pin
nickleefly9-Sep-11 23:02
membernickleefly9-Sep-11 23:02 
QuestionDisappearing Tabs... Pin
Destiny77723-Aug-11 13:40
memberDestiny77723-Aug-11 13:40 
QuestionRe: Disappearing Tabs... Pin
dam_10129-Aug-11 10:10
memberdam_10129-Aug-11 10:10 
AnswerRe: Disappearing Tabs... Pin
Destiny7772-Nov-11 8:12
memberDestiny7772-Nov-11 8:12 
GeneralTab control Pin
neerajakrishna22-Jul-10 1:34
memberneerajakrishna22-Jul-10 1:34 
GeneralOdd Behaviour and how it was resolved... Pin
Destiny7772-Jun-10 10:43
memberDestiny7772-Jun-10 10:43 
QuestionUse tab control in CFormView Pin
Member 3569264-Mar-10 6:14
memberMember 3569264-Mar-10 6:14 
GeneralAutomatically change the order of tabctrl Pin
123kloi24-Feb-10 20:12
member123kloi24-Feb-10 20:12 
GeneralRe: Automatically change the order of tabctrl Pin
123kloi24-Feb-10 20:14
member123kloi24-Feb-10 20:14 
QuestionCould you asnwer me about license? Pin
furang8-Sep-09 15:44
memberfurang8-Sep-09 15:44 
AnswerRe: Could you asnwer me about license? Pin
venura c.p.w. goonatillake8-Sep-09 16:57
membervenura c.p.w. goonatillake8-Sep-09 16:57 
QuestionIntegrated with "Rollup Control" with "Simple Tab Control For Visual C++" possible? Pin
akira3214-Jan-09 7:20
memberakira3214-Jan-09 7:20 
AnswerRe: Integrated with "Rollup Control" with "Simple Tab Control For Visual C++" possible? Pin
venura c.p.w. goonatillake14-Jan-09 14:13
membervenura c.p.w. goonatillake14-Jan-09 14:13 
GeneralFix for grey background when using new UI interface Pin
flippydeflippydebop19-Jul-07 8:35
memberflippydeflippydebop19-Jul-07 8:35 
GeneralThanx a million :) Pin
Ahmad S. Shojaeddin29-May-07 19:12
memberAhmad S. Shojaeddin29-May-07 19:12 
QuestionUnable to initialize CTab Pin
jalstadt21-Nov-06 23:05
memberjalstadt21-Nov-06 23:05 
AnswerRe: Unable to initialize CTab Pin
venura c.p.w. goonatillake21-Nov-06 23:37
membervenura c.p.w. goonatillake21-Nov-06 23:37 
QuestionRe: Unable to initialize CTab Pin
jalstadt22-Nov-06 2:02
memberjalstadt22-Nov-06 2:02 
AnswerRe: Unable to initialize CTab Pin
jalstadt22-Nov-06 1:59
memberjalstadt22-Nov-06 1:59 
GeneralRe: Unable to initialize CTab Pin
venura c.p.w. goonatillake22-Nov-06 4:01
membervenura c.p.w. goonatillake22-Nov-06 4:01 
GeneralInvalid WM_MINIMIZE handling (solution) Pin
alter gonzo8-Jun-06 2:17
memberalter gonzo8-Jun-06 2:17 
GeneralRe: Invalid WM_MINIMIZE handling (solution) Pin
venura c.p.w. goonatillake18-Jul-06 17:25
membervenura c.p.w. goonatillake18-Jul-06 17:25 
GeneralMiss-understanding GetWindow??!! Pin
Dr. Smartee14-Jul-05 0:40
memberDr. Smartee14-Jul-05 0:40 
GeneralRe: Miss-understanding GetWindow??!! Pin
venura c.p.w. goonatillake18-Jul-06 17:07
membervenura c.p.w. goonatillake18-Jul-06 17:07 
GeneralCan't Work in vc6.0 Pin
Lancelot Yuan10-Jul-05 14:39
memberLancelot Yuan10-Jul-05 14:39 
GeneralRe: Can't Work in vc6.0 Pin
Linda S11-Jul-05 12:53
memberLinda S11-Jul-05 12:53 
GeneralRe: Can't Work in vc6.0 Pin
venura c.p.w. goonatillake18-Jul-06 17:13
membervenura c.p.w. goonatillake18-Jul-06 17:13 
GeneralRe: Can't Work in vc6.0 Pin
pblais30-Apr-07 7:59
memberpblais30-Apr-07 7:59 
QuestionPotential memory leak? Pin
Osborn17-May-05 22:59
memberOsborn17-May-05 22:59 
Answertwo additional problems... Pin
Osborn17-May-05 23:19
memberOsborn17-May-05 23:19 
Questionhow to access a control in the tab from Main Dialog Pin
SteveHuang062420-Feb-05 1:06
sussSteveHuang062420-Feb-05 1:06 
AnswerRe: how to access a control in the tab from Main Dialog Pin
Holywood0724-Feb-05 4:27
memberHolywood0724-Feb-05 4:27 
AnswerRe: how to access a control in the tab from Main Dialog Pin
yingpf30-Dec-05 2:53
memberyingpf30-Dec-05 2:53 
QuestionOnMove CDialog hides -> is there any Workaroud? Pin
kim.hauser29-Nov-04 8:53
memberkim.hauser29-Nov-04 8:53 
AnswerRe: OnMove CDialog hides -> is there any Workaroud? Pin
kim.hauser29-Nov-04 9:13
memberkim.hauser29-Nov-04 9:13 
JokeRe: OnMove CDialog hides -> is there any Workaroud? Pin
Sasan12-May-06 21:36
memberSasan12-May-06 21:36 
Questionhow to create tab in mdi(no mdi tab) Pin
vc-programmer-28-Oct-04 23:51
membervc-programmer-28-Oct-04 23:51 
GeneralVertical Style not supported Pin
fredwobus27-Oct-04 21:56
memberfredwobus27-Oct-04 21:56 
Generalstrange behaviour in your demo Pin
BoscoW18-Oct-04 1:09
memberBoscoW18-Oct-04 1:09 
GeneralInvalid demo file Pin
Smitha Vijayan17-Oct-04 22:27
staffSmitha Vijayan17-Oct-04 22:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150901.1 | Last Updated 15 Oct 2004
Article Copyright 2004 by venura c.p.w. goonatillake
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid