Click here to Skip to main content
Licence 
First Posted 26 Jun 2000
Views 287,831
Bookmarked 68 times

CXTabCtrl: an easier tab control for dialogs and forms

By | 26 Jun 2000 | Article
An easier tab control

Sample Image - CXTabControl.gif

Introduction

When I first started using Microsoft VC++, I found it boring to put a tab control in a form or in a dialog. I had to create the dialogs, fill in the TCITEM structure for each of my tabs, and finally insert them into the tab control. With CXTabCtrl it is far simpler, as is illustrated below:-

InitDialog (CDialog) or InitialUpdate (CFormView) 

...
m_pMyDlg = new CMyDlg;
m_pMyDlg->Create(CMyDlg::IDD, &m_tabctrl /*CXTabCtrl variable*/);
m_tabctrl.AddTab(m_pMyDlg, "Tab caption", 0 /* image number*/);
...

The OnSelChange that you previously had to implement in the dialog (or form) to show the correct dialog is now in the CXTabCtrl, so you don't have to worry about it. You can even disable a tab so the user cannot see its contents.

m_tabctrl.EnableTab(1 /*index*/, FALSE);

You can also change the color for the following states of each tab:-

  • Selected tab
  • Unselected tab
  • Disabled tab
  • A mouse over tab
  • You can select a tab from it's caption, or dynamically change a tab. In addition to this, you can select the previous or next tab with the SelectNextTab method.

    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

    xicoloko

    Architect
    VisionOne AG
    Switzerland Switzerland

    Member

    XicoLoko is a brazilian developer based in Switzerland.


    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 Pinmemberfishpixie20:14 19 Mar '11  
    GeneralProposition Pinmembervoy k20:11 16 May '06  
    GeneralAccess the edit control inside the tab Pinmemberiulikii_02:46 26 Apr '06  
    Questionhow can i ................ Pinmemberalupiv18:35 29 Mar '06  
    QuestionHow to know which page is selected Pinmembercyberaoul22:47 5 Oct '05  
    QuestionHelp,how can i change it's size? PinmemberLancelot Yuan15:33 10 Jul '05  
    AnswerRe: Help,how can i change it's size? [modified] Pinmemberpajero_pn21:40 11 Jan '08  
    Generalprobleme whith CXTabCtrl Pinmemberchristophecrepin7:44 23 Jun '05  
    Generalhelp! How to get the value I set in tab control. PinmemberNo-Cloud-Dagon15:20 23 Feb '05  
    Generalbitmap couldn't move with SelectTab() Pinsussyenh13:41 12 Feb '04  
    GeneralProblem on Tab when enabled XP theme PinsussAnonymous13:27 16 Nov '03  
    GeneralRe: Problem on Tab when enabled XP theme PinsussAnonymous1:36 15 Jul '04  
    GeneralSub-Par Pinmemberprairiedog2k@yahoo.com9:13 21 Aug '03  
    GeneralMultiline Tab PinsussEdwin161260:04 13 Aug '03  
    GeneralRe: Multiline Tab Pinmemberpige1:49 25 Sep '07  
    GeneralHelp - Blank after re-show Pinmemberdragon745:43 23 Jul '03  
    GeneralDoesn't look good on WinXP PinsussMirzallica14:09 6 Jul '03  
    GeneralDrag and Drop in a tab Control dialog PinmemberYohome2:30 10 Jun '03  
    Generalonsize problem... Pinmemberopcode112721:00 2 Jun '03  
    GeneralBug: Inhibit Hot key Pinmemberericlts19:50 7 May '03  
    GeneralPlease Help me!! PinmemberAnsonku4:04 1 May '03  
    GeneralRe: Please Help me!! Pinmembertainy13:34 3 May '03  
    GeneralRe: Please Help me!! PinmemberPeter B.10:38 22 May '03  
    GeneralRe: Please Help me!! Pinmembercjpm1004:08 25 Jul '04  
    GeneralRe: Please Help me!! Pinmemberrthat2:40 14 Feb '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 27 Jun 2000
    Article Copyright 2000 by xicoloko
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid