Click here to Skip to main content
13,199,311 members (67,770 online)
Click here to Skip to main content
Add your own
alternative version


91 bookmarked
Posted 7 Feb 2000

Sizing TabControlBar

, 7 Feb 2000
Rate this:
Please Sign up or sign in to vote.
Creates a dockable and resizable control bar.
  • Download demo project - 46 Kb
  • Sample Image - Sizing_Tabctl.jpg

    <!-- Article Starts -->

    This article extends the article CSizingControlBar - a resizable control bar by Cristi Posea.
    Webmaster's note: the CSizingControlBar class used in this code is an earlier version; follow the link above for the latest one.


    The Control bar like in DevStudio, which has TabControls with different Views (like TreeViews) and it can be docked and resized.


    Add the following class to your project:

    • CSizingControlBar
    • CSizingTabCtrlBar

    Add a member variable to CMainFrame (in mainfrm.h):

    CSizingTabCtrlBar m_wndSTCBar;

    Create the bar in CMainFrame::OnCreate(). Then set bar styles, enable it to dock... like any control bar. Be sure to add IDW_PROP_BAR to the "resource.h" and to add the bitmap IDB_TABIMAGES to your resources.

    // SizingControlBar
    m_wndSTCBar.Create(this, CSize(200, 1), IDW_PROP_BAR);
    m_wndSTCBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
    DockControlBar(&m_wndSTCBar, AFX_IDW_DOCKBAR_LEFT);
    m_wndSTCBar.AddView("Database", RUNTIME_CLASS(CClassView));
    m_wndSTCBar.AddView("Files", RUNTIME_CLASS(CFileView));

    As you can see, the different views are added by calling

    m_wndSTCBar.AddView("Files", RUNTIME_CLASS(CFileView));

    Thats the only thing you have to do, to add a view!

    Override CMainFrame::RecalcLayout().
    Note: use the base framewnd class member function, ie if you have an SDI application replace CMDIFrameWnd with CFrameWnd below.

    void CMainFrame::RecalcLayout(BOOL bNotify) 

    To call a view from the Mainframe:

    CFileView* pView = (CFileView*)
    pView->UpdateView();	// or do anything else


    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

    Dirk Clemens
    Germany Germany
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    QuestionMainframe events gets disabled Pin
    D L Deepthi26-Apr-07 0:01
    memberD L Deepthi26-Apr-07 0:01 
    GeneralCode not maintained anymore Pin
    Dirk Clemens25-Jan-05 5:41
    memberDirk Clemens25-Jan-05 5:41 
    GeneralDamm! Not Working Pin
    dreucker_coder3-Jan-05 16:34
    memberdreucker_coder3-Jan-05 16:34 
    GeneralThe shorter way, please help fix Pin
    pank00727-Nov-04 11:28
    memberpank00727-Nov-04 11:28 
    GeneralWinFrm2.cpp and bardock errors Pin
    Furries24-Nov-04 5:46
    memberFurries24-Nov-04 5:46 
    GeneralNot work with either vs6 Pin
    pank00721-Nov-04 11:52
    memberpank00721-Nov-04 11:52 
    GeneralCommand message handling in views inside this bar Pin
    atali21-Oct-04 6:18
    memberatali21-Oct-04 6:18 
    GeneralRedraw the bar after adding a view Pin
    atali21-Oct-04 6:11
    memberatali21-Oct-04 6:11 
    Good code to start with. I couldn't combine it with Christi's latest version of CSizingControlBar, so I combined CSizingTabCtrlBar with older version of CSizingControlBar into single class. Works great.

    However, even in the original version there was a problem: If I add a view into the CSizingTabCtrlBar after it is already created, it doesn't show properly until I resize the bar. The easy workaround was to call OnSize() after adding a view.

    I added protected members to CSizingTabCtrlBar:
    int m_cx;
    int m_cy;
    UINT m_type;
    They hold last parameters passed to OnSize so I can safely call the function again.

    Code added to OnSize() after CControlBar::OnSize(nType, cx, cy);:

    // store last size so we can resize after adding a tab
    // extra check, if m_cx is 0xFDFDFDFD the thing is shutting down
    if (m_cx != 0xFDFDFDFD)
    m_cx = cx;
    m_cy = cy;
    m_type = nType;

    The last change to the class was in AddView() right before returning TRUE:

    OnSize(m_type, m_cx, m_cy);

    That takes care of the view that is added after the bar is already displayed.

    GeneralSupport for top and multiline taps Pin
    jaime_olivares8-Jul-04 14:33
    memberjaime_olivares8-Jul-04 14:33 
    GeneralBetter version Pin
    jaime_olivares8-Jul-04 14:52
    memberjaime_olivares8-Jul-04 14:52 
    QuestionBugs? Pin
    maydina24-Apr-04 3:51
    membermaydina24-Apr-04 3:51 
    GeneralProblem with CSizingTabCtrlBar by Dirk Clemens Pin
    redsome25-Mar-04 14:43
    memberredsome25-Mar-04 14:43 
    GeneralProg crash by klick on X Pin
    LowFly18-Mar-04 5:04
    memberLowFly18-Mar-04 5:04 
    GeneralMutch Better Layout Code Pin
    MOX10-Mar-04 7:28
    memberMOX10-Mar-04 7:28 
    GeneralRe: Mutch Better Layout Code Pin
    Kybert9-Apr-04 11:47
    memberKybert9-Apr-04 11:47 
    GeneralRe: Mutch Better Layout Code Pin
    Anonymous19-Apr-04 9:59
    sussAnonymous19-Apr-04 9:59 
    AnswerRe: Mutch Better Layout Code Pin
    Thornets30-Jul-08 22:52
    memberThornets30-Jul-08 22:52 
    Generalissue when closing with floating bar Pin
    avcode4-Mar-04 21:43
    memberavcode4-Mar-04 21:43 
    GeneralDocking - TOP , BOTTOM Pin
    salil_ps20-Feb-04 20:39
    membersalil_ps20-Feb-04 20:39 
    GeneralProblems with Mouse Click Pin
    salman29-Dec-03 20:04
    membersalman29-Dec-03 20:04 
    Generalwheel mouse capture problem Pin
    stevehaigh8-Nov-03 11:21
    memberstevehaigh8-Nov-03 11:21 
    GeneralClosing CSizingControlBar Pin
    D-MD31-Jul-03 10:48
    sussD-MD31-Jul-03 10:48 
    GeneralRe: Closing CSizingControlBar Pin
    xiaobin9-Aug-03 22:55
    memberxiaobin9-Aug-03 22:55 
    GeneralNot work well in 2003!! Pin
    Yoyoboy31-Jul-03 2:56
    memberYoyoboy31-Jul-03 2:56 
    GeneralRe: Not work well in 2003!! Pin
    lqhwinner3-Jun-04 2:22
    memberlqhwinner3-Jun-04 2:22 
    GeneralViews update problem solved Pin
    FretBoardKnowledge18-Dec-02 14:15
    memberFretBoardKnowledge18-Dec-02 14:15 
    GeneralRe: Views update problem solved Pin
    Philip Patrick31-Mar-03 8:15
    memberPhilip Patrick31-Mar-03 8:15 
    GeneralRe: Views update problem solved Pin
    andyvinc24-Apr-04 4:35
    memberandyvinc24-Apr-04 4:35 
    Questionhow to merge two floating dialogbar into one floating tabbed dialogbar? Pin
    YU_Matrix27-Nov-02 20:59
    memberYU_Matrix27-Nov-02 20:59 
    Questionhelp, tell me what is IDW_PROP_BAR ?? Pin
    hongky17-Nov-02 19:03
    memberhongky17-Nov-02 19:03 
    AnswerRe: help, tell me what is IDW_PROP_BAR ?? Pin
    WREY21-Jun-03 13:53
    memberWREY21-Jun-03 13:53 
    GeneralBugfix: Defect border while enlarging Pin
    Tomer Shalev12-Aug-02 21:06
    sussTomer Shalev12-Aug-02 21:06 
    GeneralIt does Not work...Help me.... Pin
    ParkSK30-Jul-02 22:39
    sussParkSK30-Jul-02 22:39 
    GeneralRe: It does Not work...Help me.... Pin
    Jawid18-Sep-02 12:07
    memberJawid18-Sep-02 12:07 
    GeneralThank you very much..It works well !! Pin
    DevPark5-Nov-03 18:01
    memberDevPark5-Nov-03 18:01 
    GeneralRe: It does Not work...Help me.... Pin
    gremyus11-Feb-04 7:57
    membergremyus11-Feb-04 7:57 
    GeneralRe: It does Not work...Help me.... Pin
    sirius yang20-Oct-04 18:14
    membersirius yang20-Oct-04 18:14 
    Questionwhy onec i created it ,my listview will not work? Pin
    xsword6-May-02 0:36
    memberxsword6-May-02 0:36 
    QuestionRedrawing the client area? Pin
    Anonymous13-Apr-02 6:37
    memberAnonymous13-Apr-02 6:37 
    AnswerRe: Redrawing the client area? Pin
    Anonymous16-May-02 6:04
    memberAnonymous16-May-02 6:04 
    GeneralRe: Redrawing the client area? Pin
    DanPetitt17-Feb-03 10:56
    memberDanPetitt17-Feb-03 10:56 
    GeneralRe: Redrawing the client area? Pin
    DanPetitt17-Feb-03 11:07
    memberDanPetitt17-Feb-03 11:07 
    GeneralRe: Redrawing the client area? Pin
    uTMan12-Nov-03 8:28
    memberuTMan12-Nov-03 8:28 
    GeneralI can't run it. It dumped failed info when creat CSizingControlBar Pin
    Crob28-Feb-02 15:15
    memberCrob28-Feb-02 15:15 
    GeneralRe: I can't run it. It dumped failed info when creat CSizingControlBar Pin
    Anonymous6-Mar-02 12:41
    memberAnonymous6-Mar-02 12:41 
    GeneralSizing Tab Control Bar Pin
    carena10-Jan-02 22:33
    membercarena10-Jan-02 22:33 
    GeneralRe: Sizing Tab Control Bar Pin
    Anonymous22-May-02 7:19
    memberAnonymous22-May-02 7:19 
    GeneralRe: Sizing Tab Control Bar Pin
    zoocmic2-Jul-02 21:50
    memberzoocmic2-Jul-02 21:50 
    GeneralRe: Sizing Tab Control Bar (lost control) Pin
    Eugene Pankov24-Jul-02 3:55
    memberEugene Pankov24-Jul-02 3:55 
    Generalslow redraw when docked under NT Pin
    thotho26-Nov-01 0:12
    memberthotho26-Nov-01 0:12 

    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.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web03 | 2.8.171020.1 | Last Updated 8 Feb 2000
    Article Copyright 2000 by Dirk Clemens
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid