Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Window commands toolbar and CExtTabMDIWnd Collapse All
Subject Author Date
Simon DESEE Oct 17, 2005 - 3:54 AM

Hello,


How can I create a toolbar for my window commands (tile, arrange icons, ...) that will be shown (or enabled) only if child windows are present ?


How can I customize my child windows caption with your CExtTabMDIWnd class (for the tab bar and the mainframe caption) ? Why isn’t the popup menu shown when I right-click on the tab bar ?


Thanks for your explanation.


Regards,

Technical Support Oct 17, 2005 - 8:38 AM

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.