0

I am using Visual Studio 2019, I created an MDI application.

I have placed 4 toolbars in a row in CMainFrame (derived from CMDIFrameWndEx). Depending on the active view I hide one toolbar, and thus it’s possible have a gap between two toolbars. How can I close the gap automatically by attaching the right toolbar to the left?

Here is my code:

LRESULT CMainFrame::OnActivateViewSelect(WPARAM w, LPARAM l)
{
    if (m_bViewInit)
    {
        auto iViewSelect = _S32(w);
        if (iViewSelect != m_lastpane)
        {
            m_lastpane = iViewSelect;
            ShowPane(&m_wndToolBar[0], iViewSelect == 0, FALSE, iViewSelect == 0);
            ShowPane(&m_wndToolBar[1], iViewSelect == 1, FALSE, iViewSelect == 1);
            ShowPane(&m_wndToolBar[2], iViewSelect == 2, FALSE, iViewSelect == 2);
            ShowPane(&m_wndToolBar[3], iViewSelect == 3, FALSE, iViewSelect == 3);
            RecalcLayout();
        }
    }
    return 0L;
}
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Oats
  • 1
  • Do you think to only disable the toolbar items instead of hide part of them ? I don't know if it's a good idea to hide toolbars, could puzzle the app user ... – Flaviu_ Oct 05 '22 at 14:19
  • I have limited screen pixel width. I cannot display all toolbars in one row at the same time unless some will be placed in next row, which limits my space below. – Oats Oct 06 '22 at 04:41
  • Perhaps using `DockPaneLeftOf(&m_wndToolBar[n], this);` where `n` is each of your toolbars and you need to repeat these line for all of them; and `this` is your Mainframe? – sergiol Oct 11 '22 at 15:50

0 Answers0