We recommend you simply create a toolbar with MDI-related commands and show/hide it when the last MDI child window closes or the first one opens. So, please override the CFrameWnd::RecalcLayout()
virtual method in your main frame window like as follows:
void CMainFrame::RecalcLayout( BOOL bNotify )
{
HWND hWndMdiClient = ::GetDlgItem( m_hWnd, AFX_IDW_PANE_FIRST );
BOOL bShow = FALSE;
BOOL bVisible = m_wndMyMdiCommandsToolBar.IsVisible() ? TRUE : FALSE;
if( hWndMdiClient != NULL )
{
HWND hWndMdiChild = ::GetWindow( hWndMdiClient, GW_CHILD );
if( hWndMdiChild != NULL )
bShow = TRUE;
}
if( bShow != bVisible )
ShowControlBar( &m_wndMyMdiCommandsToolBar, bShow, TRUE );
CMDIFrameWnd::RecalcLayout( bNotify );
}
You can customize the tab item text by overriding the
CExtTabWnd::OnTabWndQueryItemText()
virtual method in your
CExtTabMdiWnd
-derived class. This allows you to make the tab text different to the caption of the MDI child frame window and part of main frame’s caption. The
CExtTMWI
template class contains implementation of the
OnTabWndQueryItemText()
method for the MDI tab control. As you can see, the text of the tab item depends on whether your project is based on MFC’s document view architecture. So, to set the title, you can use either
CDocument::SetTitle()
or
CFrame::SetTitle()
depending on your project type. You also need to invoke the
CFrameWnd::OnUpdateFrameTitle()
virtual method to display the newly assigned title.
By default, right clicking the MDI tab bar does not produce any menu but you can change this behavior as it is done in the
ProfStudio sample. Please take a look at the
CMainFrame::OnConstructPopupMenuCB()
method in that sample. It handles the
CExtControlBar::g_nMsgConstructPopupMenu
registered windows message. The
wParam
parameter is a pointer to the
CExtControlBar::POPUP_MENU_EVENT_DATA
data structure. If the
m_nHelperNotificationType
property of this data structure is set to
__PMED_MDITABS_CTX
then the method constructs a context pop-up menu for the MDI tab window.