1
votes

I'm porting an older MFC application to use MFC feature pack with ribbon UI and have found the ribbon UI doesn't process MDI windows tiling commands such ID_WINDOW_TILE_VERT. Is there a way to enable this functionality?

Single stepping through the MFC source I get as far as the following in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\src\mfc\winmdi.cpp, which seems correct;

BOOL CMDIFrameWnd::OnMDIWindowCmd(UINT nID)
{
    ASSERT(m_hWndMDIClient != NULL);

    UINT msg;
    UINT wParam = 0;
    switch (nID)
    {
    default:
        return FALSE;       // not for us
    case ID_WINDOW_ARRANGE:
        msg = WM_MDIICONARRANGE;
        break;
    case ID_WINDOW_CASCADE:
        msg = WM_MDICASCADE;
        break;
    case ID_WINDOW_TILE_HORZ:
        wParam = MDITILE_HORIZONTAL;
        // fall through
    case ID_WINDOW_TILE_VERT:
        ASSERT(MDITILE_VERTICAL == 0);
        msg = WM_MDITILE;
        break;
    }

    ::SendMessage(m_hWndMDIClient, msg, wParam, 0);
    return TRUE;
}

I have also tried calling

MDITile(MDITILE_HORIZONTAL);

directly, which essentially does the same thing and does not work.

1

1 Answers

0
votes

From some experimentation, when the MFC mdi interface is based on CMDIFrameWndEx frames hosting dockable panes based CMDIChildWndEx and tabbed documents are enabled, floating windows are not available and hence neither are tiling or cascading.

To enable tiling, simply remove the line

EnableMDITabbedGroups(TRUE, mdiTabParams);

from your CMainFrame::OnCreate method. The downside is you also lose your nice tabbed document UI. FWIW, I also tried calling EnableDocking(CBRS_FLOAT_MULTI) after enabling tabbed groups, but it does not make any difference. Also under discussion here

Update: In order to keep the tabbed interface and split the screens, the following alternative works well to split a single horizontal view with multiple tabs into two views, with current tab in the new view.

void SplitViews(CMDIFrameWndEx *pFrame) 
{   
    pFrame->MDITabNewGroup();
    pFrame->MDITabMoveToNextGroup(); 
}