To activate the resizable control bar including when it is auto hidden, just send the WM_COMMAND
message to the main frame window. Do not forget to specify control bar’s dialog control identifier in the WPARAM
parameter. The same can be done with the following code:
CExtControlBar::DoFrameBarCheckCmd(
pMainFrame,
nBarID,
false
);
Please note that if you use the auto-hide feature, you need to implement the following versions of MFC’s
OnBarCheck()
and
OnUpdateControlBarMenu()
methods in the main frame window:
BOOL CMainFrame::OnBarCheck(UINT nID)
{
return
CExtControlBar::DoFrameBarCheckCmd(
this,
nID,
false
);
}
void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
{
CFrameWnd::OnUpdateControlBarMenu( pCmdUI );
CExtControlBar::DoFrameBarCheckUpdate(
this,
pCmdUI,
false
);
}
To hide the window that is sliding from the auto-hide area, send the
WM_CANCELMODE
message to it. The control bar’s child window is temporarily moved into the auto-hide slider window (which looks exactly like resizable control bar). So, you can analyze the parent window and if it is not the control bar, then it is the auto-hide slider window and you can send the
WM_CANCELMODE
message. We may assume you have the following
CMainFrame
members:
CExtControlBar m_wndBar;
CSomeWindow m_wndInsideBar;
The
m_wndInsideBar
window was created as a child of the
m_wndBar
window. So, we can easily detect whether the
m_wndInsideBar
is displayed in the auto-hide grouped tabs:
CWnd * pWndParent = m_wndInsideBar.GetParent();
if( pWndParent->m_hWnd != m_wndBar.m_hWnd )
pWndParent->SendMessage( WM_CANCELMODE );