Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - How to add the second toolbar NEXT TO
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to add the second toolbar NEXT TO

 Post Reply Post Reply
Author
Message
Onur View Drop Down
Groupie
Groupie


Joined: 17 August 2005
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Onur Quote  Post ReplyReply Direct Link To This Post Topic: How to add the second toolbar NEXT TO
    Posted: 17 August 2005 at 10:37pm

Hi,

How do I "add" the second toolbar right NEXT TO the first one?
The code is:

CommandBar TB1 = CommandBars.Add("Toolbar 1", XTPBarPosition.xtpBarTop);
CommandBar TB2 = CommandBars.Add("Toolbar 2", XTPBarPosition.xtpBarTop);

Both added to the top of the form but one under the other.

Thanks in advance

Back to Top
Onur View Drop Down
Groupie
Groupie


Joined: 17 August 2005
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Onur Quote  Post ReplyReply Direct Link To This Post Posted: 17 August 2005 at 11:27pm
Found my solution from SuperMario's answer to another post..
Re-syntaxeed for C#..

private void DockToolbarOnRightOf(CommandBar BarToDock, CommandBar BarOnLeft)

{

int left, top, right, bottom;

CommandBars.RecalcLayout();

BarOnLeft.GetWindowRect(out left, out top, out right, out bottom);

CommandBars.DockToolBar(BarToDock, right, (bottom + top) / 2, BarOnLeft.Position);

}

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2005 at 12:14pm
Thought this might be useful...had it laying around from another help request.  It allows toolbars to be docked text to each other when vertical as well:

You can use this helper function to dock a toolbar to the right of another:

private void DockRightOf(XtremeCommandBars.CommandBar BarToDock, XtremeCommandBars.CommandBar BarOnLeft, Boolean VerticalBar)
{
int left, top, right, bottom;
XtremeCommandBars.CommandBar LeftBar = BarOnLeft;
 
CommandBars.RecalcLayout();
LeftBar.GetWindowRect(out left, out top, out right, out bottom);

if (VerticalBar == false)
CommandBars.DockToolBar(BarToDock, right, (bottom + top) / 2, LeftBar.Position);
else
CommandBars.DockToolBar(BarToDock, (left + right) / 2, Bottom, LeftBar.Position);
}

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:
   XtremeCommandBars.CommandBar ToolBar, ThemesBar;
   //..........Add controls to toolbars
   DockRightOf(ThemesBar, ToolBar, false);
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 26 October 2005 at 11:56am
Here is both the C# and VB version:

Question:
How do I Place One or More ToolBars on the Same Row?

Answer:
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.

In the picture below, you can see that toolbar #2 has been docked next to toolbar #1. This was done using code.

The code below provides a helper function that will dock a toolbar to the right of another, regardless of the order that the toolbars are added. This code will allow you to dock a toolbar next to another wheather it is vertical or horizontal.

C# Code

// C# Code
private void DockRightOf(XtremeCommandBars.CommandBar BarToDock,
XtremeCommandBars.CommandBar BarOnLeft, Boolean VerticalBar)
{
int left, top, right, bottom;
XtremeCommandBars.CommandBar LeftBar = BarOnLeft;

CommandBars.RecalcLayout();
LeftBar.GetWindowRect(out left, out top, out right, out bottom);

if (VerticalBar == false)
CommandBars.DockToolBar(BarToDock, right,
(bottom + top) / 2, LeftBar.Position);
else
CommandBars.DockToolBar(BarToDock, (left + right) / 2,
Bottom, LeftBar.Position);
}

/*
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:
XtremeCommandBars.CommandBar ToolBar1, ToolBar2;
//..........Add controls to toolbars
DockRightOf(ToolBar2, ToolBar1, false);
*/

VB6 Code
' VB6 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.