Sizing TabControlBar
Posted
by Dirk Clemens
on August 7th, 1998
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
change wndSTCBar size by code
Posted by Legacy on 01/29/2004 12:00amOriginally 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:00amOriginally 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
}
ReplyNOTE: 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:00amOriginally 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:
ReplyThanks for the code. Will definitely use the control as a model for other development.
http://www.codejock.com
Posted by Legacy on 06/08/2003 12:00amOriginally 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:00amOriginally posted by: Shaun Cooley
ReplyDebug Assert -- CSizingControlBar::Create() --
Posted by Legacy on 04/01/2003 12:00amOriginally posted by: milkyway
ReplyDebug assertion at DockControlBar(&m_wndSTCBar, AFX_IDW_DOCKBAR_LEFT); in real application
Posted by Legacy on 03/07/2003 12:00amOriginally 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
ReplyRe-docking, Resetting Defaults
Posted by Legacy on 01/22/2003 12:00amOriginally 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!
ReplyNo more flickering
Posted by Legacy on 09/11/2002 12:00amOriginally 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...
ReplyNitin
Problem of flickring in Tree View
Posted by Legacy on 09/09/2002 12:00amOriginally posted by: Nitin
ReplyLoading, Please Wait ...