Click here to Skip to main content
Click here to Skip to main content

CXTabCtrl: an easier tab control for dialogs and forms

By , 26 Jun 2000
 
<!-- Link to demo file download --> <!-- Article image -->

Sample Image - CXTabControl.gif

<!-- Add the rest of your HTML here -->

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

     
    Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
    You must Sign In to use this message board.
    Search this forum  
        Spacing  Noise  Layout  Per page   
    Generalbitmap couldn't move with SelectTab()sussyenh12-Feb-04 13:41 
    GeneralProblem on Tab when enabled XP themesussAnonymous16-Nov-03 13:27 
    GeneralRe: Problem on Tab when enabled XP themesussAnonymous15-Jul-04 1:36 
    GeneralSub-Parmemberprairiedog2k@yahoo.com21-Aug-03 9:13 
    GeneralMultiline TabsussEdwin1612613-Aug-03 0:04 
    GeneralRe: Multiline Tabmemberpige25-Sep-07 1:49 
    GeneralHelp - Blank after re-showmemberdragon7423-Jul-03 5:43 
    GeneralDoesn't look good on WinXPsussMirzallica6-Jul-03 14:09 
    GeneralDrag and Drop in a tab Control dialogmemberYohome10-Jun-03 2:30 
    Generalonsize problem...memberopcode11272-Jun-03 21:00 
    GeneralBug: Inhibit Hot keymemberericlts7-May-03 19:50 
    GeneralPlease Help me!!memberAnsonku1-May-03 4:04 
    GeneralRe: Please Help me!!membertainy3-May-03 13:34 
    GeneralRe: Please Help me!!memberPeter B.22-May-03 10:38 
    GeneralRe: Please Help me!!membercjpm10025-Jul-04 4:08 
    GeneralRe: Please Help me!!memberrthat14-Feb-05 2:40 
    GeneralRe: Please Help me!!memberrthat14-Feb-05 5:32 
    Generalhwo can iset icon to the tabmemberliquidsnake18329-Mar-03 11:47 
    GeneralModifying Text on Tabsussmistroseth26-Mar-03 2:20 
    GeneralFormViewmemberDscho6-Feb-03 22:23 
    GeneralFormView Samplememberbpwallac25-Jan-03 18:20 
    GeneralCTabCtrlSSL is bettermembernomadik12-Jan-03 23:36 
    GeneralRe: CTabCtrlSSL is bettermemberericlts7-May-03 19:25 
    GeneralRe: CTabCtrlSSL is bettermemberdchris_med24-Apr-08 14:13 
    GeneralExcellent job!!!memberkevindu9-Jan-03 14:00 
    QuestionKeyboard navigation?sussAnonymous1-Nov-02 22:06 
    Generaldynamic delete tabsmembersilverspoon24-Jul-02 22:01 
    GeneralRe: dynamic delete tabssussAnonymous2-Aug-02 0:54 
    QuestionHow to set the caption dynamically ?memberKumar119-Feb-02 17:40 
    AnswerRe: How to set the caption dynamically ?memberminuo22-Mar-02 9:38 
    GeneralRe: How to set the caption dynamically ?sussAnonymous19-Sep-02 8:02 
    Generalno tabsmemberAMW9-Nov-01 19:31 
    GeneralMore instructions pleasememberAnonymous21-Sep-01 4:17 
    GeneralRe: More instructions pleasememberRabentochter25-Jul-02 22:47 
    QuestionHow can I do to transfert datas ?memberyoussef24-Aug-01 0:08 
    AnswerRe: How can I do to transfert datas ?memberchhlud22-Apr-03 6:17 
    GeneralRe: How can I do to transfert datas ?memberyoussef22-Apr-03 6:33 
    GeneralRe: How can I do to transfert datas ?memberchhlud23-Apr-03 2:11 
    GeneralRe: How can I do to transfert datas ?memberYohome9-Jun-03 7:21 
    GeneralRe: How can I do to transfert datas ?memberyoussef9-Jun-03 7:23 
    GeneralRe: How can I do to transfert datas ?memberYohome9-Jun-03 7:32 
    AnswerRe: How can I do to transfert datas ?memberfabioo6-May-03 5:33 
    GeneralRe: How can I do to transfert datas ?sussseedy21-May-03 6:16 
    QuestionCan I get the sample project with FORMVIEW (not dialog based)?memberAnonymous26-May-01 22:23 
    AnswerRe: Can I get the sample project with FORMVIEW (not dialog based)?memberallex23-Jun-01 0:53 
    GeneralRe: Can I get the sample project with FORMVIEW (not dialog based)?memberAnonymous24-Jul-01 12:01 
    GeneralRe: Can I get the sample project with FORMVIEW (not dialog based)?memberAMW24-Aug-01 3:15 
    GeneralRe: Can I get the sample project with FORMVIEW (not dialog based)?membertkha7-Nov-01 15:02 
    GeneralSpawn a new windowmemberAnonymous27-Apr-01 11:38 
    GeneralRe: Spawn a new windowmemberAnonymous20-Aug-01 2:30 

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

    Permalink | Advertise | Privacy | Mobile
    Web03 | 2.6.130619.1 | Last Updated 27 Jun 2000
    Article Copyright 2000 by xicoloko
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid