Click here to Skip to main content
15,879,348 members
Articles / Desktop Programming / MFC
Article

Sizing TabControlBar

Rate me:
Please Sign up or sign in to vote.
3.65/5 (23 votes)
7 Feb 2000 345.9K   4.6K   92   77
Creates a dockable and resizable control bar.
  • Download demo project - 46 Kb
  • Sample Image - Sizing_Tabctl.jpg

    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.

    Features

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

    Instructions

    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 Image 2 to your resources.

    // SizingControlBar
    m_wndSTCBar.Create(this, CSize(200, 1), IDW_PROP_BAR);
    m_wndSTCBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
    	CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
    m_wndSTCBar.EnableDocking(CBRS_ALIGN_ANY);
    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) 
    {
    	CMDIFrameWnd::RecalcLayout(bNotify);
    	CMDIFrameWnd::RecalcLayout(bNotify);
    }

    To call a view from the Mainframe:

    CFileView* pView = (CFileView*)
    	m_wndSTCBar.GetView(RUNTIME_CLASS(CFileView));
    pView->UpdateView();	// or do anything else
    m_wndSTCBar.SetActiveView(RUNTIME_CLASS(CFileView));

    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
    Germany Germany
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralRe: I can't run it. It dumped failed info when creat CSizingControlBar Pin
    6-Mar-02 12:41
    suss6-Mar-02 12:41 
    GeneralSizing Tab Control Bar Pin
    10-Jan-02 22:33
    suss10-Jan-02 22:33 
    GeneralRe: Sizing Tab Control Bar Pin
    22-May-02 7:19
    suss22-May-02 7:19 
    GeneralRe: Sizing Tab Control Bar Pin
    fromdj2-Jul-02 21:50
    fromdj2-Jul-02 21:50 
    GeneralRe: Sizing Tab Control Bar (lost control) Pin
    Jevgenij Pankov24-Jul-02 3:55
    Jevgenij Pankov24-Jul-02 3:55 
    Generalslow redraw when docked under NT Pin
    26-Nov-01 0:12
    suss26-Nov-01 0:12 
    GeneralRemove a view Pin
    23-Nov-01 3:16
    suss23-Nov-01 3:16 
    GeneralCanging Labeltext of Tabs while Resizing Pin
    Joerg Tiedemann13-Nov-01 22:45
    Joerg Tiedemann13-Nov-01 22:45 
    Hi,
    if I resize the Control Bar the Text of the Tablabels didn't change. What must i do to get the same funtion like the Tabcontrol in Visual Studio.
    The Labeltext should be to cut short with Text and Dots to the Label Dimensions (i.e. "Data..." for Text "Database")

    Thanks for every solution or answer

    GeneralProblem by closing ControlBar Pin
    25-Oct-01 21:28
    suss25-Oct-01 21:28 
    GeneralRe: Problem by closing ControlBar Pin
    28-Oct-01 23:17
    suss28-Oct-01 23:17 
    GeneralRe: Problem by closing ControlBar Pin
    28-Oct-01 23:28
    suss28-Oct-01 23:28 
    QuestionStart with no default document ?? Pin
    23-Oct-01 20:26
    suss23-Oct-01 20:26 
    GeneralProblem with new ver CSizingControlBar and AddView() Pin
    19-Oct-01 3:48
    suss19-Oct-01 3:48 
    QuestionX-button problem? Pin
    18-Oct-01 22:22
    suss18-Oct-01 22:22 
    QuestionHow to create workspace Window? Pin
    24-Sep-01 23:52
    suss24-Sep-01 23:52 
    GeneralAdd a ListView Pin
    Franz Klein17-Jun-01 23:27
    Franz Klein17-Jun-01 23:27 
    GeneralRe: Add a ListView Pin
    Park KeunHyun16-Sep-01 17:29
    Park KeunHyun16-Sep-01 17:29 
    GeneralDagbog Pin
    16-Mar-01 22:16
    suss16-Mar-01 22:16 
    GeneralProblems with Visual Studio 6 Pin
    Craig Spry12-Oct-00 13:00
    sussCraig Spry12-Oct-00 13:00 
    GeneralRe: Problems with Visual Studio 6 Pin
    rmcd13-Oct-00 13:23
    rmcd13-Oct-00 13:23 
    GeneralRe: Problems with Visual Studio 6 Pin
    Lacoruna15-Jul-02 21:22
    Lacoruna15-Jul-02 21:22 
    Generalno ENTER, no ESCAPE Messages in TreeView Pin
    Thomas Barthel28-Aug-00 10:05
    sussThomas Barthel28-Aug-00 10:05 
    GeneralRe: no ENTER, no ESCAPE Messages in TreeView Pin
    31-Jul-01 9:56
    suss31-Jul-01 9:56 
    GeneralProblem in AddView(....) Pin
    Sanjay BORA6-Aug-00 18:50
    Sanjay BORA6-Aug-00 18:50 
    GeneralRe: Problem in AddView(....) Pin
    Sanjay BORA15-Aug-00 16:00
    Sanjay BORA15-Aug-00 16:00 

    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.