Click here to Skip to main content
Licence 
First Posted 14 Oct 2004
Views 164,651
Bookmarked 51 times

Simple Tab Control For Visual C++

By | 14 Oct 2004 | Article
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

About the Author

venura c.p.w. goonatillake

Software Developer (Senior)

Sri Lanka Sri Lanka

Member

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++.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 3 Pinmemberbuyong16:51 24 Oct '11  
QuestionUse NTGraph as a resizeable control in the CTabCtrl-class object PinmemberMember 789153517:56 19 Sep '11  
Questionexe file Pinmembernickleefly23:02 9 Sep '11  
QuestionDisappearing Tabs... PinmemberDestiny77713:40 23 Aug '11  
QuestionRe: Disappearing Tabs... Pinmemberdam_10110:10 29 Aug '11  
AnswerRe: Disappearing Tabs... PinmemberDestiny7778:12 2 Nov '11  
GeneralTab control Pinmemberneerajakrishna1:34 22 Jul '10  
GeneralOdd Behaviour and how it was resolved... PinmemberDestiny77710:43 2 Jun '10  
QuestionUse tab control in CFormView PinmemberMember 3569266:14 4 Mar '10  
GeneralAutomatically change the order of tabctrl Pinmember123kloi20:12 24 Feb '10  
GeneralRe: Automatically change the order of tabctrl Pinmember123kloi20:14 24 Feb '10  
QuestionCould you asnwer me about license? Pinmemberfurang15:44 8 Sep '09  
AnswerRe: Could you asnwer me about license? Pinmembervenura c.p.w. goonatillake16:57 8 Sep '09  
QuestionIntegrated with "Rollup Control" with "Simple Tab Control For Visual C++" possible? Pinmemberakira327:20 14 Jan '09  
AnswerRe: Integrated with "Rollup Control" with "Simple Tab Control For Visual C++" possible? Pinmembervenura c.p.w. goonatillake14:13 14 Jan '09  
GeneralFix for grey background when using new UI interface Pinmemberflippydeflippydebop8:35 19 Jul '07  
GeneralThanx a million :) PinmemberAhmad S. Shojaeddin19:12 29 May '07  
QuestionUnable to initialize CTab Pinmemberjalstadt23:05 21 Nov '06  
AnswerRe: Unable to initialize CTab Pinmembervenura c.p.w. goonatillake23:37 21 Nov '06  
QuestionRe: Unable to initialize CTab Pinmemberjalstadt2:02 22 Nov '06  
AnswerRe: Unable to initialize CTab Pinmemberjalstadt1:59 22 Nov '06  
GeneralRe: Unable to initialize CTab Pinmembervenura c.p.w. goonatillake4:01 22 Nov '06  
GeneralInvalid WM_MINIMIZE handling (solution) Pinmemberalter gonzo2:17 8 Jun '06  
GeneralRe: Invalid WM_MINIMIZE handling (solution) Pinmembervenura c.p.w. goonatillake17:25 18 Jul '06  
GeneralMiss-understanding GetWindow??!! PinmemberDr. Smartee0:40 14 Jul '05  

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.

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