Question : toolbars position

when i resize the main frame (MDI application), the toolbars reposition one beneath the other, i'd like them to reposition back after resize again so the will be dockable side by side in the same row like in the begining of the running.

relevant code;

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
      if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
      
      VERIFY(m_MDIClient.SubclassWindow(m_hWndMDIClient));

      if (!m_wndToolBar.Create(this) ||
            !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
      {
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create
      }

      if (!m_wndZ3ToolBar1.Create(this) ||
            !m_wndZ3ToolBar1.LoadToolBar(IDR_Z3_TOOLBAR1))
      {
            TRACE0("Failed to create Z3 toolbar1\n");
            return -1;      // fail to create
      }

      if (!m_wndRegToolBar.Create(this) ||
            !m_wndRegToolBar.LoadToolBar(IDR_REG_TOOLBAR))
      {
            TRACE0("Failed to create registration toolbar1\n");
            return -1;      // fail to create
      }

      if (!m_wndMatchToolBar.Create(this) ||
            !m_wndMatchToolBar.LoadToolBar(IDR_MATCH_TOOLBAR))
      {
            TRACE0("Failed to create matching toolbar\n");
            return -1;      // fail to create
      }

      if (!m_wndExpToolBar.Create(this) ||
            !m_wndExpToolBar.LoadToolBar(IDR_EXP_TOOLBAR))
      {
            TRACE0("Failed to create matching toolbar\n");
            return -1;      // fail to create
      }

      if (!m_wndZowToolBar.Create(this) ||
            !m_wndZowToolBar.LoadToolBar(IDR_ZOW_TOOLBAR))
      {
            TRACE0("Failed to create Z3 on web toolbar\n");
            return -1;      // fail to create
      }

      if (!m_wndDebugToolBar.Create(this) ||
            !m_wndDebugToolBar.LoadToolBar(IDR_DEBUGGING_TOOLBAR))
      {
            TRACE0("Failed to create debug toolbar1\n");
            return -1;      // fail to create
      }

      if (!m_wndStatusBar.Create(this) ||
            !m_wndStatusBar.SetIndicators(indicators,
              sizeof(indicators)/sizeof(UINT)))
      {
            TRACE0("Failed to create status bar\n");
            return -1;      // fail to create
      }

    if (!m_wndTalbar.Create(_T("Tal Bar"), this, CSize(200, 100), TRUE, 123))
    {      //AFX_IDW_CONTROLBAR_FIRST + 33))

        TRACE0("Failed to create Talbar\n");
        return -1;      // fail to create
      }

      m_wndTalbar.SetBarStyle(m_wndTalbar.GetBarStyle() |
        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

      // TODO: Remove this if you don't want tool tips or a resizeable toolbar
      // at this stage I have no use for a resizeable toolbar.
      m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER );

      m_wndZ3ToolBar1.SetBarStyle(m_wndZ3ToolBar1.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER );

      m_wndRegToolBar.SetBarStyle(m_wndRegToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER );

      m_wndMatchToolBar.SetBarStyle(m_wndMatchToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER );

      m_wndExpToolBar.SetBarStyle(m_wndExpToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER );

      m_wndZowToolBar.SetBarStyle(m_wndZowToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER );

      m_wndDebugToolBar.SetBarStyle(m_wndDebugToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER );


      // TODO: Delete these five lines if you don't want the toolbar to
      //  be dockable
      // note the **** order!! first enable, then dock.
      // see mfc example: doctool
      m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
      m_wndZ3ToolBar1.EnableDocking(CBRS_ALIGN_ANY);
      m_wndRegToolBar.EnableDocking(CBRS_ALIGN_ANY);
      m_wndMatchToolBar.EnableDocking(CBRS_ALIGN_ANY);
      m_wndExpToolBar.EnableDocking(CBRS_ALIGN_ANY);
      m_wndZowToolBar.EnableDocking(CBRS_ALIGN_ANY);
      m_wndDebugToolBar.EnableDocking(CBRS_ALIGN_ANY);
      m_wndTalbar.EnableDocking(CBRS_ALIGN_LEFT);

      EnableDocking(CBRS_ALIGN_ANY);

      DockControlBar(&m_wndToolBar,AFX_IDW_DOCKBAR_TOP);
      DockControlBarLeftOf(&m_wndZ3ToolBar1,&m_wndToolBar);
      DockControlBarLeftOf(&m_wndRegToolBar,&m_wndZ3ToolBar1);
      DockControlBarLeftOf(&m_wndMatchToolBar,&m_wndRegToolBar);
      DockControlBarLeftOf(&m_wndExpToolBar,&m_wndMatchToolBar);
      DockControlBarLeftOf(&m_wndZowToolBar,&m_wndExpToolBar);
      DockControlBarLeftOf(&m_wndDebugToolBar,&m_wndZowToolBar);
      DockControlBar(&m_wndTalbar, AFX_IDW_DOCKBAR_LEFT);

Answer : toolbars position

Map CMainFrame's WM_SIZE and again call

DockControlBarLeftOf(&m_wndZ3ToolBar1,&m_wndToolBar);
     DockControlBarLeftOf(&m_wndRegToolBar,&m_wndZ3ToolBar1);
     DockControlBarLeftOf(&m_wndMatchToolBar,&m_wndRegToolBar);
     DockControlBarLeftOf(&m_wndExpToolBar,&m_wndMatchToolBar);
     DockControlBarLeftOf(&m_wndZowToolBar,&m_wndExpToolBar);
     DockControlBarLeftOf(&m_wndDebugToolBar,&m_wndZowToolBar);
     DockControlBar(&m_wndTalbar, AFX_IDW_DOCKBAR_LEFT);


THis will work...

cheers
Random Solutions  
 
programming4us programming4us