Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to dock mutiple toolbars in a row ?

Posted on 1999-06-25
1
Medium Priority
?
689 Views
Last Modified: 2013-11-20
Dear experts
I'm using VC++5.0 in WindowsNT4.0.
I'd like to dock mutiple toolbars in a row, i.e. top row.
I tried as following codes.
Where I created 4 toolbars.
As you see, my app has three mode(user interface is changed in each mode), and each mode has its toolbar. So the other toolbars are hided.
But one of four toolbars, m_wndCommonToolbar, is displayed in every mode.
Anyway, problem is they (i.e. anyone of mode toolbar and m_wndCommonToolbar) aren't docked in a row.
At start up, they(e.g. DesignToolbar and Common toolbar) has its own row. i.e. So, totally two rows.
Even I dragged they into a row, if I changed mode and come back, they (including status bar) are scattered again.
Any comments will be appreciated.
---- source code ------
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
      CWnd wnd;

      WINDOWPLACEMENT windowInfo;
      windowInfo.length = sizeof( WINDOWPLACEMENT );
      windowInfo.showCmd = SW_HIDE;

      if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
      SetWindowPos( &wnd, 0, 0, 1024, 768, 0 );

      m_wndDesignToolBar.CreateToolBar(this, IDR_MAINFRAME ); // CBRS_SIZE_DYNAMIC flag is set.

      m_wndDesignToolBar.SetBarStyle(m_wndDesignToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY );

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

      m_wndPlayToolBar.SetBarStyle(m_wndPlayToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

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

      m_wndMotionToolBar.SetBarStyle(m_wndMotionToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

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

      m_wndCommonToolBar.SetBarStyle(m_wndCommonToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

      m_wndDesignToolBar.EnableDocking(CBRS_ALIGN_TOP);
      m_wndPlayToolBar.EnableDocking(CBRS_ALIGN_TOP);
      m_wndMotionToolBar.EnableDocking(CBRS_ALIGN_TOP);
      m_wndCommonToolBar.EnableDocking(CBRS_ALIGN_TOP);
      EnableDocking(CBRS_ALIGN_TOP);

      RecalcLayout();

      CRect rtWnd;

      m_wndDesignToolBar.GetWindowRect(rtWnd);
      rtWnd.OffsetRect(0, -72);
      DockControlBar(&m_wndDesignToolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
      RecalcLayout();

      m_wndCommonToolBar.GetWindowRect(rtWnd); // having 3 buttons
      rtWnd.OffsetRect(950, 0);
      DockControlBar(&m_wndCommonToolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
      RecalcLayout();


      m_wndPlayToolBar.GetWindowRect(rtWnd);
      // rtWnd.OffsetRect(0, 0);
      DockControlBar(&m_wndPlayToolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
      RecalcLayout();

      m_wndMotionToolBar.GetWindowRect(rtWnd);
      // rtWnd.OffsetRect(0, 0);
      DockControlBar(&m_wndMotionToolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
      RecalcLayout();

      ShowControlBar(&m_wndCommonToolBar, TRUE, FALSE);
      ShowControlBar(&m_wndDesignToolBar, TRUE, FALSE);
      ShowControlBar(&m_wndMotionToolBar, FALSE, FALSE);
      ShowControlBar(&m_wndPlayToolBar, FALSE, FALSE);

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

      //
      SetCursor( LoadCursor( NULL, IDC_ARROW ) );

      return 0;
}

0
Comment
Question by:okg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
naveenkohli earned 200 total points
ID: 1307947
Here is the sample code for doing that. You calculate the rectangle of docking frame. Offset the rectangle by 1 unit. And then in call to DockCintrolBAr specify the side to which you want to dock the new bar with respect to existing one.

You can make use of this code and write a helper function to do this job.

********************************

CRect rect;
CToolBar *pExistingToolBar, *pNewToolBar;

CFrameWnd *pFrame = pExistingToolBar->GetDockingFRame ();

pFrame->ReCalcLayout ();

pExistingToolBar->GetWindowRect (&rect);

rect.Offset (1,1);

pFrame->DockControlBar (pNewToolBar, nToolBarID, &rect);


Cheers!!

GoodLuck



0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question