Sizing TabControlBar

Download Source Code and Example


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

Features

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 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));

Last updated: 14 May 1998



Comments

  • Alle topkwaliteit door Dr Dre koptelefoon

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

    [url=http://koptelefoon-monsterbeats.tumblr.com/]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=http://koptelefoon-monsterbeats.weebly.com/]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=http://monsterkoptelefoon.npage.de/]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.

    Reply
  • 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?

    Reply
  • Bug Fix: refresh tab

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

    Originally posted by: Mike Dawn

    Hello:)

    Here is more bug fix:

    void CSizingTabCtrlBar::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)
    {
    SetActiveView(m_tabctrl.GetCurSel());

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


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

    Reply
  • 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 CAUSE:
    -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);
    }
    else
    {
    // activate this view
    //Apollo: Nope, don't even think about it :-)
    //pParentFrame->SetActiveView(this);
    }
    }
    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.

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

    Reply
  • http://www.codejock.com

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

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

    http://www.codejock.com

    Reply
  • 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);
    with:
    if(pContext->m_pNewDocTemplate->IsKindOf(RUNTIME_CLASS(CMultiDocTemplate)))
    ((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...
    -Shaun

    Reply
  • 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);

    Reply
  • 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

    Hi!
    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:
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    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.

    Thanks

    Sanjay Gupta

    Reply
  • 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!

    Reply
  • 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...


    Nitin

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds