Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Add 2 toolbars in 1 line
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Add 2 toolbars in 1 line

 Post Reply Post Reply
Author
Message
Voha View Drop Down
Newbie
Newbie
Avatar

Joined: 22 March 2004
Location: Canada
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Voha Quote  Post ReplyReply Direct Link To This Post Topic: Add 2 toolbars in 1 line
    Posted: 01 April 2004 at 11:37am

Hi all!

I cannot find solution how to add 2nd toolbar near 1st. It always add next toolbar below the previous. I dock them all at the top.

In Infragistics ActiveToolBar there is a solution when DocRow and DockColumn properties should be specified.

May be i just missed somethig? But there is no any axample where tollbars whould be loaded in such way. But it is possible to move 2nd toolbar manualy . So i think sulution exist but i just cannot find it.

tnx.

Voha

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: 01 April 2004 at 11:58am
Look at CommandBars dynamic popup sample.  Copy the code below to a new project and add a CommandBars control and ImageList control if you want images:

Private Sub DockRightOf(BarToDock As CommandBar, BarOnLeft As CommandBar)
    Dim Left As Long
    Dim Top As Long
    Dim Right As Long
    Dim Bottom As Long
   
    CommandBars.RecalcLayout
    BarOnLeft.GetWindowRect Left, Top, Right, Bottom
   
    CommandBars.DockToolBar BarToDock, Right, (Bottom + Top) / 2, BarOnLeft.Position

End Sub

Private Sub Form_Load()

    Dim Control As CommandBarControl
    Dim ControlFile As CommandBarPopup
   
    Set ControlFile = CommandBars.ActiveMenuBar.Controls.Add(xtpControlPopup, 0, "&File", -1,0)
    With ControlFile.CommandBar.Controls
        .Add xtpControlButton, ID_FILE_NEW, "&New", -1, False
    End With
   
    Dim ToolBar As CommandBar
   
    Set ToolBar = CommandBars.Add("Standard", xtpBarTop)
    With ToolBar.Controls
        Set Control = .Add(xtpControlButton, ID_FILE_NEW, "&New", -1, False)
        Control.DescriptionText = "Create a new document"
    End With
   
    Dim ExtendedBar As CommandBar
    Set ExtendedBar = CommandBars.Add("Extended", xtpBarTop)
    With ExtendedBar.Controls
        Set Control = .Add(xtpControlSplitButtonPopup, ID_TOOLS_UNDO, "Undo")
        Control.CommandBar.Controls.Add xtpControlButton, ID_TOOLS_UNDO, "Undo"
       
        .Add xtpControlComboBox, ID_TOOLS_UNDO_COMBO, "Undo Combo"
    End With
   
    CommandBars.AddImageList imlToolbarIcons
   
    DockRightOf ExtendedBar, ToolBar
End Sub


Edited by SuperMario
Back to Top
MarcelN View Drop Down
Newbie
Newbie


Joined: 20 December 2004
Location: Netherlands
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote MarcelN Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2005 at 7:41am

When using this method to dock a toolbar to the right, it's still positioned wrong.
Although it is on the same line as the other toolbar, it's positioned too far to the right. (We're using C#, Visual Studio 2005 Beta 2)

I debugged our application and found the values returned from GetWindowRect to be very weird:
left: 2700
top: 3330
right: 11070
bottom: 3735

Also, the width of the toolbar is too large.
Width: 32767

Are these values in pixels? The values seem a bit high.

I do have a multi-monitor setup, but after disabling my second monitor it still wouldn't work correctly.

These toolbars should be aligned next to eachother, not that far apart.
Is there a solution for this problem, or are we doing something wrong?

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 May 2005 at 9:51am
I don't have VS 2005 Beta 2 to test on, but here is the C# code I use:


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);
}

Also, make sure you are adding your icons BEFORE you use this function.
Back to Top
MarcelN View Drop Down
Newbie
Newbie


Joined: 20 December 2004
Location: Netherlands
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote MarcelN Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2005 at 6:06am
Thank you Mario (but our princess is in another castle...),

Since I don't know which icons belong to the toolbar items, I solved the problem another way.
By adding the toolbars from right to left, it's possible to dock the next toolbar on the left. For this the size of the toolbars doesn't matter :)

I do have another question though.
(still using C# in Visual Studio 2005 beta 2)

I copy some menu-items from a .net ToolStrip to a CodeJock CommandBar.
.net uses a ToolStripControlHost for custom controls, similar to the CommandBarControlCustom class.

The CommandBarControlCustom class needs the handle of a control, which can be assigned via a property.

The problem is this:
We have a dynamic toolbar, which can change over time. When it changes the entire CommandBar is cleared, and new controls are added. Whenever a CommandBarControlCustom item is present and the CommandBar is cleared + filled again, the custom control is still visible (but not usable)

By moving over the control with the mouse the application crashes with the following error: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt"

It only occurs when CommandBarControlCustom items are used.

Does the CommandBarControls.DeleteAll() method release all the handles to controls properly? Or could there be another problem (and solution)?

==== EDIT ====
By manually releasing the handles of CommandBarControlCustom items, it does work as expected.

for (int i = 1; i < this.m_BarDynamic.Controls.Count; i++)

{
    if (!(this.m_BarDynamic.Controls is CommandBarControlCustom))
        continue;

    CommandBarControlCustom control = this.m_BarDynamic.Controls as CommandBarControlCustom;

    IntPtr Handle = new IntPtr(control.Handle);
    if (Handle == IntPtr.Zero)
        continue;

    NativeWindow window = NativeWindow.FromHandle(Handle);
    window.DestroyHandle();
}


==== EDIT ====

More progress...
I created a CommandBarControlCustom object with a Handle to a .net TextBox. This worked, the textbox was shown correctly :)

One problem does occur though. When another CommandBarControl is added AFTER the Custom control, the backspace key doesn't work.

Even worse, there are some focus problems with custom .net UserControls in a CommandBarControlCustom object. This always occurs, even when the Custom control isn't followed by another control.

Edited by MarcelN
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.172 seconds.