Sizing TabControlBar

Download Source Code and Example

This article extends the article "Resizable Docking Window 2" by Cristi Posea.


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:

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

Last updated: 14 May 1998


  • Alle topkwaliteit door Dr Dre koptelefoon

    Posted by mrswanzi on 06/06/2013 12:23pm

    [url=]beats by dre[/url] De Monster urBeats by Dr. Dre in-ear-koptelefoon is een ultralichte in-ear hoofdtelefoon met geluid van hoge kwaliteit. De Monster urBeats hoofdtelefoon produceert een verbluffend geluid en schept de illusie dat uw favoriete band of DJ recht voor u staat! De ware Beats-liefhebber wist misschien al van deze verrassing af, maar toch willen we het via deze weg openbaar maken. Binnenkort zitten er weer nieuwe Monster producten aan te komen, die wederom onder het Beats By Dr. Dre label worden gentroduceerd. Het gaat om de urBeats in-ears, die garant staan voor een gedetailleerde audioperformance, een robuuste constructie en een comfortabele pasvorm. [url=]beats by dre kopen[/url] Spelen werd de populariteit van de Monster Beats by Dr. Dre hoofdtelefoons weer aangetoond.Zelfs een waarschuwing van het IOC, het Internationaal Olympisch Comit¨¦, kon niet voorkomen dat diverse sporters voor hun wedstrijden te zien waren met een Beats by Dr. Dre op het hoofd. Beats by Dre is in korte tijd ongekend populair geworden, mede dankzij de sporters tijdens de Olympische Spelen. Maar waar komt die populariteit ineens vandaan [url=]beats by dre kopen[/url] Met de Monstercable Beats Dr. Dr¨¦ gaat u op in de muziek terwijl u vergeet dat u een hoofdtelefoon draagt. De oorschelpen zijn groot en comfortabel dankzij soepele kussentjes van zacht en geventileerd materiaal. De Beats hoofdtelefoon heeft bovendien een glanzend design en is krasbestendig.

  • change wndSTCBar size by code

    Posted by Legacy on 01/29/2004 12:00am

    Originally posted by: helpme

    I want to change the size of the m_wndSTCBar by code , how can I do it?

  • Bug Fix: refresh tab

    Posted by Legacy on 09/30/2003 12:00am

    Originally posted by: Mike Dawn


    Here is more bug fix:

    void CSizingTabCtrlBar::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)

    // refresh the screen
    Invalidate(TRUE); // clear window
    UpdateWindow(); // redraw the screen

    NOTE: This will refresh the GUI inside toolbar went you select tab change.

  • MDIAccelerator (Ctrl+F6, +F4, +TAB, ...) Bug

    Posted by Legacy on 06/19/2003 12:00am

    Originally posted by: Apollo Cabrera

    THE BUG:
    -Start the demo app.
    -Click on the file new icon in the standard toolbar. This creates another mdichildframe and corresponding view.
    -Press Ctrl+F6 and the views change
    -Click on the Tree View in the Tab Control
    -Press Ctrl+F6 and the views do not change.

    -The Ctrl+F6 is really two WM_KEYDOWN events. Those are walked up the CWnd::PreTranslateMessage(...) chain.

    -CMDIFrameWnd (the parent of CMainFrame) has an implementation that calls ::TranslateMDISysAccel which generates the WM_SYSCOMMAND, SC_NEXTWINDOW message. The ::TranslateMDISysAccel is only invoked if CMDIFrameWnd::m_pActiveView is null.

    -When you click on one of the views in the tab control, a WM_MOUSE_ACTIVATE message is generated.

    -CView (the parent of CClassView, ...) has a handler for this event which traverses the parent windows until it finds a class that is a type CFrameWnd. CView sets CFrameWnd's active view to the CView.

    -Since CClassView does not exists within a CChildFrame, it finds CMainFrame and sets itself as the active view.

    -The ::TranslateMDISysAccel will no longer be called and Ctrl+F6, Ctrl+F4, Ctrl+Tab (and other MDI Translated events) will not work.

    THE FIX:
    -Intercept the WM_MOUSE_ACTIVATE event. Same implementation as CView, but don't set the frame's active view.

    int CClassView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
    int nResult = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
    if (nResult == MA_NOACTIVATE || nResult == MA_NOACTIVATEANDEAT)
    return nResult; // frame does not want to activate

    CFrameWnd* pParentFrame = GetParentFrame();
    if (pParentFrame != NULL)
    // eat it if this will cause activation
    ASSERT(pParentFrame == pDesktopWnd || pDesktopWnd->IsChild(pParentFrame));

    // either re-activate the current view, or set this view to be active
    CView* pView = pParentFrame->GetActiveView();
    HWND hWndFocus = ::GetFocus();
    if (pView == this &&
    m_hWnd != hWndFocus && !::IsChild(m_hWnd, hWndFocus))
    // re-activate this view
    OnActivateView(TRUE, this, this);
    // activate this view
    //Apollo: Nope, don't even think about it :-)
    return nResult;

    -You could also create an actual CFrameWnd for the views, but that would require a little bit more coding and changing how CSizingTabCtrlBar works.

    Thanks for the code. Will definitely use the control as a model for other development.


    Posted by Legacy on 06/08/2003 12:00am

    Originally posted by: The Best GUI Tools - VS.NET and Office XP/2003 Look!

  • Two Fixes

    Posted by Legacy on 05/29/2003 12:00am

    Originally posted by: Shaun Cooley

    Below are two fixes for bugs reported about CCJTabCtrlBar.

    The first one is a bug fix for the error reported by Mahmoud Saleh, which is:
    1. activate/click one of the views of the CCJTabCtrlBar
    2. Float the control bar
    3. close the control bar
    The result is that the application partially freezes by no longer processing most of the messages (e.g., menus or buttons).
    This is fixed by replacing the following code on line 240:
    ((CFrameWnd *)GetParent())->SetActiveView((CView *)m_pActiveView);
    ((CFrameWnd *)GetParent())->SetActiveView((CView *)m_pActiveView);

    The second bug was reported by myself. The bug is if you pass NULL for the CCreateContext variable of AddView(), in a SDI, the File->Save and the save button on the toolbar are disabled.

    The fix is to pass in a valid CCreateContext. Simple enough... however, AddView lets you only pass in the first two and has the context set to NULL by default... it should not, because it doesn't handle it correctly.

    Hope this helps everyone out...

  • Debug Assert -- CSizingControlBar::Create() --

    Posted by Legacy on 04/01/2003 12:00am

    Originally posted by: milkyway

    BOOL CSizingControlBar::Create(CWnd* pParentWnd, CSize sizeDefault, UINT nID, DWORD dwStyle)
    ASSERT_VALID(pParentWnd); // must have a parent
    ASSERT (!((dwStyle & CBRS_SIZE_FIXED) && (dwStyle & CBRS_SIZE_DYNAMIC)));

    // save the style
    // Original code
    // m_dwStyle = dwStyle;
    // Modifyed code
    m_dwStyle = (dwStyle & CBRS_ALL);

  • Debug assertion at DockControlBar(&m_wndSTCBar, AFX_IDW_DOCKBAR_LEFT); in real application

    Posted by Legacy on 03/07/2003 12:00am

    Originally posted by: Sanjay Gupta

    I tested the example in VC6. It caused Debug Assertion failure at Create function of CSizingTabCtrlBar for first time. I rectified it using tips from the comment "Using Sizing TabControlBar with VC6 (2)". Next time it again raised Debug Assertion at following call:

    DockControlBar(&m_wndSTCBar, AFX_IDW_DOCKBAR_LEFT);

    Im using MDI framework and for your kind information Im using Toolbar and a Dialog bar embedded within a Rebar. I thought whether rebar is causing DocControlBar to raise Debug Assertion. I commented all Rebar based code. But still problem persisted. Even If I try to Doc toolbar calling:
    DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_LEFT);

    DockControlBar still causes Debug Assertion even for Toolbar or Dialog Bar. If anybody knows the reason of failure and have solution please suggest me.


    Sanjay Gupta

  • Re-docking, Resetting Defaults

    Posted by Legacy on 01/22/2003 12:00am

    Originally posted by: Matt O'Neill

    I've got an application that uses this object and the engineers I work with can't figure out how to 'reset' the workspace. For instance, users will sometimes drag their workspace off the desktop or will undock it or put it in a nonstandard location. I'd like to provide a method by which they can "reset workspace" which would move it to the default location at the bottom of the application window and dock it there. We have only been able to acheieve this by forcing the user to log out and then log back in, at which time it is in the default location. Otherwise, it moves to the default location and docks but is not re-sizeable or movable and can eat up valuable screen real estate in the application but can't be resized.

    Are you aware of any way within the standard object code that this can be accomplished? InterDev seems to do it, so there must be someway to acheive it.

    Thanks for any help you can provide!

  • No more flickering

    Posted by Legacy on 09/11/2002 12:00am

    Originally posted by: Nitin

    Hi All,
    I have found the simplest solution for flickering problem. I was having the problem that i mentioned in my post, i was also having the problem of flickering of all the three docking window that i added in my application.
    To avoid flickering just set the WS_CLIP_CHILDREN style with other general windows style. Set this style for all the child windows and u will be free from flickering...


  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date