Click here to Skip to main content
15,435,837 members
Articles / Desktop Programming / MFC
Article
Posted 26 Jun 2000

Stats

365.6K views
7.7K downloads
77 bookmarked

CXTabCtrl: an easier tab control for dialogs and forms

Rate me:
Please Sign up or sign in to vote.
4.44/5 (31 votes)
26 Jun 2000
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


    Written By
    Architect VisionOne AG
    Switzerland Switzerland
    XicoLoko is a brazilian developer based in Switzerland.

    Comments and Discussions

     
    QuestionCan I get the sample project with FORMVIEW (not dialog based)? Pin
    26-May-01 22:23
    suss26-May-01 22:23 
    AnswerRe: Can I get the sample project with FORMVIEW (not dialog based)? Pin
    23-Jun-01 0:53
    suss23-Jun-01 0:53 
    GeneralRe: Can I get the sample project with FORMVIEW (not dialog based)? Pin
    24-Jul-01 12:01
    suss24-Jul-01 12:01 
    GeneralRe: Can I get the sample project with FORMVIEW (not dialog based)? Pin
    24-Aug-01 3:15
    suss24-Aug-01 3:15 
    GeneralRe: Can I get the sample project with FORMVIEW (not dialog based)? Pin
    7-Nov-01 15:02
    suss7-Nov-01 15:02 
    GeneralSpawn a new window Pin
    27-Apr-01 11:38
    suss27-Apr-01 11:38 
    GeneralRe: Spawn a new window Pin
    20-Aug-01 2:30
    suss20-Aug-01 2:30 
    GeneralUse class with existing Property Sheet Pin
    Bob Eastman14-Apr-01 16:51
    MemberBob Eastman14-Apr-01 16:51 
    I have tried without success to incorporate this class into an existing property sheet.

    Is there a demo project available showing how to do so?

    tia
    GeneralThree Improvements Pin
    Darren S. Gonzales15-Feb-01 10:30
    MemberDarren S. Gonzales15-Feb-01 10:30 
    GeneralRe: Three Improvements Pin
    3-Jul-01 13:42
    suss3-Jul-01 13:42 
    GeneralRe: Three Improvements Pin
    lpvoid6-Nov-02 3:18
    Memberlpvoid6-Nov-02 3:18 
    GeneralRe: Three Improvements Pin
    lpvoid6-Nov-02 3:20
    Memberlpvoid6-Nov-02 3:20 
    GeneralThe tabclass control cannot be used on already created dialogs by MFC wizards. Pin
    31-Jan-01 1:43
    suss31-Jan-01 1:43 
    GeneralRe: The tabclass control cannot be used on already created dialogs by MFC wizards. Pin
    10-Oct-01 5:20
    suss10-Oct-01 5:20 
    GeneralThe tabclass control cannot be used on already created dialogs by MFC wizards. Pin
    31-Jan-01 1:42
    suss31-Jan-01 1:42 
    GeneralOnsize when showing dialog Pin
    Matt Philmon4-Oct-00 7:50
    MemberMatt Philmon4-Oct-00 7:50 
    GeneralRe: Onsize when showing dialog Pin
    Matt Philmon4-Oct-00 10:58
    MemberMatt Philmon4-Oct-00 10:58 
    GeneralRe: Onsize when showing dialog Pin
    25-Apr-02 14:06
    suss25-Apr-02 14:06 
    QuestionTab not visible? Pin
    Goh Choon Liang26-Sep-00 6:33
    MemberGoh Choon Liang26-Sep-00 6:33 
    AnswerRe: Tab not visible? Pin
    Matt Philmon2-Oct-00 16:24
    MemberMatt Philmon2-Oct-00 16:24 
    GeneralRe: Tab not visible? Pin
    31-Jan-01 23:00
    suss31-Jan-01 23:00 
    AnswerRe: Tab not visible? Pin
    TJ Houston6-Jun-02 22:56
    MemberTJ Houston6-Jun-02 22:56 
    AnswerRe: Tab not visible? Pin
    nomadik12-Jan-03 22:30
    Membernomadik12-Jan-03 22:30 

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

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