Click here to Skip to main content
11,702,130 members (65,556 online)
Click here to Skip to main content

Docking Toolbars Side-By-Side

, 15 Dec 1999 206.9K 2.7K 56
Rate this:
Please Sign up or sign in to vote.
Demonstrates how to dock toolbars side-by-side
  • Download demo project - 29 Kb
  • Sample Image - toolbar_docking.gif

    <!-- Article Starts -->

    There are many articles about docking toolbars, however, I felt that this was important enough to mention here. The same information can be found at Microsofts MSDN site, here it is in a nutshell: Add the following method to your CMainFrame class:

    void CMainFrame::DockControlBarLeftOf(CToolBar* Bar, CToolBar* LeftOf)
    	CRect rect;
    	DWORD dw;
    	UINT n;
    	// get MFC to adjust the dimensions of all docked ToolBars
    	// so that GetWindowRect will be accurate
    	n = 0;
    	n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
    	n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
    	n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
    	// When we take the default parameters on rect, DockControlBar will dock
    	// each Toolbar on a seperate line. By calculating a rectangle, we
    	// are simulating a Toolbar being dragged to that location and docked.

    Now, in your CMainFrame::OnCreate, instead of using DockControlBar, use DockControlBarLeftOf:


    This will dock m_wndToolBar2 left of m_wndToolBar1.


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Kirk Stowell
    CEO Codejock Software
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    GeneralBeautiful Pin
    nadiric31-Aug-06 16:04
    membernadiric31-Aug-06 16:04 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web04 | 2.8.150819.1 | Last Updated 16 Dec 1999
    Article Copyright 1999 by Kirk Stowell
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid