|
Support
ActiveX / COM
Visual C++ / MFC
Customer Spotlight
Corporate Partners
Contact Sales
Call center available M-F 9:00 - 6:00 US Eastern Time. U.S. and Canada International Email |
Adding One or More ToolBars on the Same Row
Author: Mike Palmatier
Posted: October 20, 2005
Environment: Visual Basic 6.0
By default, when a toolbar is added, the toolbar appears on a separate row. Each toolbar added will then appear under the previous toolbar.
However, many times it is useful to dock a toolbar next to another on the same row using code.
Private Sub DockRightOf(BarToDock As CommandBar, _ BarOnLeft As CommandBar, VerticalBar As Boolean) Dim Left As Long Dim Top As Long Dim Right As Long Dim Bottom As Long Dim LeftBar As CommandBar
Set LeftBar = BarOnLeft
CommandBars.RecalcLayout BarOnLeft.GetWindowRect Left, Top, Right, Bottom
LeftBar.GetWindowRect Left, Top, Right, Bottom
If (VerticalBar = False) Then CommandBars.DockToolBar BarToDock, Right, _ (Bottom + Top) / 2, LeftBar.Position Else CommandBars.DockToolBar BarToDock, (Left + Right) _ / 2, Bottom, LeftBar.Position End If End Sub
'Parameters: ' BarToDock - ToolBar to be placed to ' - the RIGHT of another ToolBar ' BarOnLeft - ToolBar that will be on the LEFT side of BarToDock ' VerticalBar - Set to false if the toolbars are docked at the ' top or bottom of the window (horizontal), set to ' true if the toolbars are on the left or right of ' the window (vertical).
'Sample usage: ' Dim ToolBar1 As CommandBar, ToolBar2 As CommandBar ' ..........Add controls to toolbars ' DockRightOf ToolBar2, ToolBar1, False |
