Click here to Skip to main content
13,288,104 members (52,930 online)
Click here to Skip to main content
Add your own
alternative version


56 bookmarked
Posted 15 Dec 1999

Docking Toolbars Side-By-Side

, 15 Dec 1999
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 Technologies, LLC
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    QuestionHow to remove the empty space in front of toolbar2 if uncheck view->toolbar Pin
    jd0120-Nov-06 14:20
    memberjd0120-Nov-06 14:20 
    GeneralBeautiful Pin
    nadiric31-Aug-06 17:04
    membernadiric31-Aug-06 17:04 
    GeneralToolBar 1 not displayed properly Pin
    Abhi Lahare22-May-06 21:18
    memberAbhi Lahare22-May-06 21:18 
    QuestionHow to control the position of the docking toolbar if the main frame window is resized? Pin
    Mary Gao12-Apr-05 14:49
    memberMary Gao12-Apr-05 14:49 
    AnswerRe: How to control the position of the docking toolbar if the main frame window is resized? Pin
    mark-w20-Dec-05 17:48
    membermark-w20-Dec-05 17:48 
    GeneralRe: How to control the position of the docking toolbar if the main frame window is resized? Pin
    jd0122-Nov-06 9:20
    memberjd0122-Nov-06 9:20 
    GeneralOdd Artifacts Pin
    Bob Ciora30-Jan-05 6:52
    memberBob Ciora30-Jan-05 6:52 
    GeneralThanks! Pin
    Bob Ciora28-Jan-05 10:49
    memberBob Ciora28-Jan-05 10:49 
    GeneralClasses Derived from CToolBar Pin
    NoahNNFN11-Jan-05 8:59
    sussNoahNNFN11-Jan-05 8:59 
    GeneralRe: Classes Derived from CToolBar Pin
    icaro14-Jun-06 11:33
    membericaro14-Jun-06 11:33 
    Generalremoving border/seperator Pin
    socall0113-Dec-04 10:26
    membersocall0113-Dec-04 10:26 
    GeneralRe: removing border/seperator Pin
    Lars [Large] Werner17-Mar-05 4:41
    memberLars [Large] Werner17-Mar-05 4:41 
    GeneralRe: removing border/seperator Pin
    Anonymous12-Jul-05 19:59
    sussAnonymous12-Jul-05 19:59 
    GeneralRe: removing border/seperator Pin
    Albert Holguin3-Oct-13 12:06
    memberAlbert Holguin3-Oct-13 12:06 
    GeneralThanks alot! Pin
    ipichet19-Oct-04 2:27
    memberipichet19-Oct-04 2:27 
    GeneralDisplaying the Toolbar 2 Pin
    Audalio_Jr12-May-04 8:14
    memberAudalio_Jr12-May-04 8:14 
    GeneralRe: Displaying the Toolbar 2 Pin
    Dave_B24-Aug-04 23:41
    memberDave_B24-Aug-04 23:41 
    GeneralRe: Displaying the Toolbar 2 Pin
    KJ Dugan21-Nov-04 5:05
    memberKJ Dugan21-Nov-04 5:05 
    Generalsimple and easy, thanks! Pin
    John Wong9-Sep-02 11:57
    memberJohn Wong9-Sep-02 11:57 
    QuestionHow to Docking More than Three Toolbars Side-By-Side?? Pin
    Anonymous5-Jun-02 20:02
    memberAnonymous5-Jun-02 20:02 
    AnswerRe: How to Docking More than Three Toolbars Side-By-Side?? Pin
    mjwilliamson19-Sep-03 5:17
    membermjwilliamson19-Sep-03 5:17 
    GeneralRe: How to Docking More than Three Toolbars Side-By-Side?? Pin
    PMartos26-Apr-04 8:31
    memberPMartos26-Apr-04 8:31 
    GeneralShort and sweet Pin
    Frank Wittmann12-Apr-02 0:14
    memberFrank Wittmann12-Apr-02 0:14 
    GeneralThanks again! Pin
    Jamie Hale22-Feb-02 9:46
    memberJamie Hale22-Feb-02 9:46 
    GeneralThanks!! Pin
    RobJones17-Feb-02 12:10
    memberRobJones17-Feb-02 12:10 
    GeneralFor CDialogBar Pin
    Falk23-Aug-01 8:02
    memberFalk23-Aug-01 8:02 
    QuestionHow can I dock a toolbar in the center of the application? Pin
    Danielle15-Jan-00 8:28
    sussDanielle15-Jan-00 8:28 
    AnswerRe: How can I dock a toolbar in the center of the application? Pin
    toxcct30-Jun-05 7:04
    membertoxcct30-Jun-05 7:04 

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

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

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.171207.1 | Last Updated 16 Dec 1999
    Article Copyright 1999 by Kirk Stowell
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid