When a toolbar floats, the MFC framework normally supplies a window menu (formerly
known as system menu) to the toolbar. The toolbar can be floated by a double click or by
dragging it to the center of the screen. This code demonstrates how to do it.
Note: I could not get the mini frame window to repaint. So I had to first hide and then
show the toolbar to achieve the same effect. I tried UpdateWindow, SetWindowPos,
MoveWindow etc. Suggestions welcome.
1. Derive your own toolbar CMyToolBar from CToolBar and update the m_wndToolBar member
in the main frame.
2. In CMyToolBar::OnLButtonDblClk(…), add the following:
CToolBar::OnLButtonDblClk(...); //fill the parameters if (IsFloating()) //is toolbar floating { CWnd* pMiniFrame; CWnd* pDockBar; pDockBar = GetParent(); pMiniFrame = pDockBar->GetParent(); //get rid of window menu pMiniFrame->ModifyStyle(WS_SYSMENU, NULL); //extreme way of re-painting the toolbar pMiniFrame->ShowWindow(SW_HIDE); pMiniFrame->ShowWindow(SW_SHOW); }
3. Repeat same code in OnLButtonDown(…) and elsewhere.