Implementing Docking control Bar in Child Frame

In a multiple view application, sometimes I need to implement different control bars for different views. This article presents how to implement docking control bar in a child frame. Suppose we want to embed a tool bar and a status bar in a child frame. First, declare them in ChildFrm.h:
protected: // control bar embedded members ... CStatusBar m_wndStatusBar; CToolBar m_wndToolBar; static UINT indicators[4]; // indicators of status bar
Next, over write CChildFrame::OnCreate(). Create control bars just as we do in CmainFrame.
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// TODO: Delete these three lines if you don't want the toolbar to be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
Then write the array of status bar' indicators as following:
UINT CChildFrame::indicators[4] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
Now you can build the project and play with it. However, the menu item "Tool Bar" does not work properly at this stage. When there is any child frame in the main frame, the menu effects the tool bar in the child frame only. You can't toggle the show/hide of the tool bar in the main frame until you close all the child frames. Now I am going to create 2 new menu terms, Main Frame Tool Bar, and Child Frame Tool Bar, to toggle show/hide of the 2 tool bars. Use ClassWizard to add following 2 member functions in CMainFrame.
void CMainFrame::OnViewMainframetoolbar()
{
// TODO: Add your command handler code here
if(m_wndToolBar.IsWindowVisible())
m_wndToolBar.ShowWindow(SW_HIDE);
else
m_wndToolBar.ShowWindow(SW_SHOW);
this->SendMessage(WM_SIZE, 0, 0);
}
void CMainFrame::OnUpdateViewMainframetoolbar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_wndToolBar.IsWindowVisible());
}
Similarly add following member functions in CChildFrame.
void CChildFrame::OnViewChildframetoolbar()
{
// TODO: Add your command handler code here
if(m_wndToolBar.IsWindowVisible())
m_wndToolBar.ShowWindow(SW_HIDE);
else
m_wndToolBar.ShowWindow(SW_SHOW);
this->SendMessage(WM_SIZE, 0, 0);
}
void CChildFrame::OnUpdateViewChildframetoolbar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_wndToolBar.IsWindowVisible());
}
Build the project and see how the menu items work. The same technique works for ReBar. If you have any qestion, feel free to drop me a line.

Comments
The activities the competition has been doing in the matter of nike and the things that you want to complete totally different.
Posted by icoppyapedcap on 04/21/2013 09:26pmKy [url=http://hunter-rain-boots.webnode.jp]ã¬ã¤ã³ãã¼ããã³ã¿ã¼[/url] eVt [url=http://hunterrainbootsjp.webnode.jp]ã¬ã¤ã³ãã¼ãã¡ã³ãº[/url] u VnyYpf ZqzA [url=http://hunter-boots8.webnode.jp]ã¬ã¤ã³ãã¼ããã³ã¿ã¼[/url] bt W [url=http://rain-boots-men.webnode.jp]ãã³ã¿ã¼é·é´[/url] lz [url=http://hunter-rain-boots-ja.webnode.jp]ã¬ã¤ã³ãã¼ã人æ°[/url] NxoUzpTbq Y[url=http://rainshoesja.webnode.jp]ãã¼ã[/url] jiNqtJokDv [url=http://ja-hunter-rain-boots.webnode.jp]ã¬ã¤ã³ãã¼ããã³ã¿ã¼[/url] c QprDsr [url=http://rain-boots-popular.webnode.jp]ã¬ã¤ã³ãã¼ãã¡ã³ãº[/url] Njt [url=http://rain-boots-men6.webnode.jp]ãã³ã¿ã¼ã¬ã¤ã³ãã¼ã[/url] Yyf Sbk [url=http://jahunterrainboots.webnode.jp]ãã³ã¿ã¼ãã¼ã[/url] Zit
ReplyHow to draw the toolbar background?
Posted by Legacy on 10/10/2003 12:00amOriginally posted by: zzfa
I found that your menubar'color differ from toolbar's,Can you tell me how to draw the toolbar background where is no button?
Replythank you very much!
docking toolbar in Windows SDK??
Posted by Legacy on 05/05/2001 12:00amOriginally posted by: Shibu J
How do I add a docking toolbar with images on each button in Windows Platform SDK?
ReplyToolbar in a view?
Posted by Legacy on 07/17/1999 12:00amOriginally posted by: Tesic Goran
Reply