Click here to Skip to main content
15,867,488 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.6K   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

     
    GeneralRedraw the bar after adding a view Pin
    atali21-Oct-04 6:11
    atali21-Oct-04 6:11 

    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.