Print Page | Close Window

RESOLVED: Positioning Help!! (Screenshot added)

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=11331
Printed Date: 15 June 2025 at 6:01pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: RESOLVED: Positioning Help!! (Screenshot added)
Posted By: JasonG
Subject: RESOLVED: Positioning Help!! (Screenshot added)
Date Posted: 07 July 2008 at 3:09pm
Allow me to throw a curve.

I have 2 CommandBar controls on a form (commandBar and commandBar2). CommandBar is on the form itself, while CommandBar2 is on a frame (actually a picturebox) that gets moved around the form as the form is resized or splitters are changed. Each CommandBar control is used to control ONE toolbar.

This works perfectly, as expected.

However, now I want to add a 2nd toolbar to CommandBar2 - this is no problem, however - I would like this 3rd toolbar to be right-aligned when the form is resized.

I assume there is a change to the "DockRightOf" function, but the measurements escape me for some reason.

Any help would be greatly appreciated!

Screenshot: http://www.trackmybookings.com/pimages/commandbar.jpg - http://www.trackmybookings.com/pimages/commandbar.jpg






Code:

Sub InitializeCommandBar()

    CommandBars.DeleteAll
    CommandBars2.DeleteAll

    Dim ToolBar As CommandBar
    Dim ReplyBar As CommandBar
    Dim ReplyBar2 As CommandBar
    Dim C As CommandBarButton
   
    'MAIN TOOLBAR (ON FORM)
    Set ToolBar = CommandBars.Add("Standard", xtpBarTop)
    ToolBar.Customizable = False
    ToolBar.ContextMenuPresent = False
    ToolBar.ShowExpandButton = False
    ToolBar.ShowGripper = False
    Set C = ToolBar.Controls.Add(xtpControlButton, 1, "New")
    Set C = ToolBar.Controls.Add(xtpControlButton, 2, "Print")
    Set C = ToolBar.Controls.Add(xtpControlButton, 3, "Forward")
    Set C = ToolBar.Controls.Add(xtpControlButton, 4, "Chat")
    Set C = ToolBar.Controls.Add(xtpControlButton, 5, "Rotate")
    Set C = ToolBar.Controls.Add(xtpControlButton, 6, "Skin")
    ToolBar.ShowTextBelowIcons = True
    ToolBar.SetIconSize 32, 32
    ToolBar.EnableDocking xtpFlagHideWrap
   
   
    'SECONDARY TOOLBAR (FIRST ON FRAME)
    Set ReplyBar = CommandBars2.Add("Reply", xtpBarTop)
    ReplyBar.Customizable = False
    ReplyBar.ContextMenuPresent = False
    ReplyBar.ShowExpandButton = False
    ReplyBar.ShowGripper = False
    Set C = ReplyBar.Controls.Add(xtpControlButton, 7, "Send")
    Set C = ReplyBar.Controls.Add(xtpControlButton, 8, "Send Later")
    Set C = ReplyBar.Controls.Add(xtpControlButton, 9, "Send All")
    Set C = ReplyBar.Controls.Add(xtpControlSplitButtonPopup, 10, "Acknowledge")
    Set C = ReplyBar.Controls.Add(xtpControlButton, 11, "CC")
    ReplyBar.ShowTextBelowIcons = True
    ReplyBar.SetIconSize 32, 32
    ReplyBar.EnableDocking xtpFlagHideWrap


    'TERTIARY TOOLBAR (SECOND ON FRAME, RIGHT ALIGNED)
    Set ReplyBar2 = CommandBars2.Add("Reply2", xtpBarTop)
    ReplyBar2.Customizable = False
    ReplyBar2.ContextMenuPresent = False
    ReplyBar2.ShowExpandButton = False
    ReplyBar2.ShowGripper = False
    Set C = ReplyBar2.Controls.Add(xtpControlButton, 12, "Re-Send")
    Set C = ReplyBar2.Controls.Add(xtpControlButton, 13, "Trash")
    ReplyBar2.ShowTextBelowIcons = True
    ReplyBar2.SetIconSize 32, 32
    'ReplyBar2.EnableDocking xtpFlagHideWrap

    '
-----------ICON CODE REMOVED-----------

    Call DockRightOf(ReplyBar2, ReplyBar)  
   
End Sub

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
   
    CommandBars2.RecalcLayout
    BarOnLeft.GetWindowRect Left, Top, Right, Bottom
    CommandBars2.DockToolBar BarToDock, Right, (Bottom + Top) / 2, BarOnLeft.Position
End Sub




Replies:
Posted By: ijwelch
Date Posted: 07 July 2008 at 8:12pm
Add these lines:

    ReplyBar.EnableDocking xtpFlagStretchedShared Or xtpFlagHideWrap
    ReplyBar2.EnableDocking xtpFlagStretchedShared Or xtpFlagHideWrap



before:
    Call DockRightOf(ReplyBar2, ReplyBar)
  


Posted By: JasonG
Date Posted: 08 July 2008 at 8:47am
This yields the same result - the second bar is still docking to the immediate right of the first... Any other Ideas?


Sub InitializeCommandBar()

    CommandBars.DeleteAll
    CommandBars2.DeleteAll

    Dim ToolBar As CommandBar
    Dim ReplyBar As CommandBar
    Dim ReplyBar2 As CommandBar
    Dim C As CommandBarButton
   
    Set ToolBar = CommandBars.Add("Standard", xtpBarTop)
    ToolBar.Customizable = False
    ToolBar.ContextMenuPresent = False
    ToolBar.ShowExpandButton = False
    ToolBar.ShowGripper = False
    Set C = ToolBar.Controls.Add(xtpControlButton, 1, "New")
    Set C = ToolBar.Controls.Add(xtpControlButton, 2, "Print")
    Set C = ToolBar.Controls.Add(xtpControlButton, 3, "Forward")
    Set C = ToolBar.Controls.Add(xtpControlButton, 4, "Chat")
    Set C = ToolBar.Controls.Add(xtpControlButton, 5, "Rotate")
    Set C = ToolBar.Controls.Add(xtpControlButton, 6, "Skin")
    ToolBar.ShowTextBelowIcons = True
    ToolBar.SetIconSize 32, 32
    ToolBar.EnableDocking xtpFlagHideWrap
   
   
    Set ReplyBar = CommandBars2.Add("Reply", xtpBarTop)
    ReplyBar.Customizable = False
    ReplyBar.ContextMenuPresent = False
    ReplyBar.ShowExpandButton = False
    ReplyBar.ShowGripper = False
    Set C = ReplyBar.Controls.Add(xtpControlButton, 7, "Send")
    Set C = ReplyBar.Controls.Add(xtpControlButton, 8, "Send Later")
    Set C = ReplyBar.Controls.Add(xtpControlButton, 9, "Send All")
    Set C = ReplyBar.Controls.Add(xtpControlSplitButtonPopup, 10, "Acknowledge")
    Set C = ReplyBar.Controls.Add(xtpControlButton, 11, "CC")
    ReplyBar.ShowTextBelowIcons = True
    ReplyBar.SetIconSize 32, 32
    ReplyBar.EnableDocking xtpFlagHideWrap Or xtpFlagHideWrap


    Set ReplyBar2 = CommandBars2.Add("Reply2", xtpBarTop)
    ReplyBar2.Customizable = False
    ReplyBar2.ContextMenuPresent = False
    ReplyBar2.ShowExpandButton = False
    ReplyBar2.ShowGripper = False
    Set C = ReplyBar2.Controls.Add(xtpControlButton, 12, "Re-Send")
    Set C = ReplyBar2.Controls.Add(xtpControlButton, 13, "Trash")
    ReplyBar2.ShowTextBelowIcons = True
    ReplyBar2.SetIconSize 32, 32
    ReplyBar2.EnableDocking xtpFlagHideWrap Or xtpFlagHideWrap


    Dim Items()
    Items = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
    ImageManager.Icons.LoadBitmap App.Path & "\Icons\highclr.bmp", Items, xtpImageNormal
    CommandBars.Icons = ImageManager.Icons
    CommandBars2.Icons = ImageManager.Icons

   
    Call DockRightOf(ReplyBar2, ReplyBar)
 
End Sub

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
    Dim Left2 As Long
    Dim Top2 As Long
    Dim Right2 As Long
    Dim Bottom2 As Long
   
   
    CommandBars2.RecalcLayout
    BarOnLeft.GetWindowRect Left, Top, Right, Bottom
    BarToDock.GetWindowRect Left2, Top2, Right2, Bottom2
    CommandBars2.DockToolBar BarToDock, Right, (Bottom + Top) / 2, BarOnLeft.Position
End Sub






Posted By: Oleg
Date Posted: 08 July 2008 at 12:39pm
try
 
instead
CommandBars2.DockToolBar BarToDock, Right, (Bottom + Top) / 2, BarOnLeft.Position
CommandBars2.DockToolBar BarToDock, Right + 1000, (Bottom + Top) / 2, BarOnLeft.Position


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: JasonG
Date Posted: 08 July 2008 at 12:48pm
I see that this will offset the toolbar by 1000, however I am trying to get the width of the parent frame, and the width of replybar2, and use those measurements to place it all the way to the right. Using your method would not work if the form/frame was resized.

also, the offset doesnt even work... weird...


Posted By: jpbro
Date Posted: 08 July 2008 at 12:53pm
I found this hack that seems to work...Add it after your current last ReplyBar.Controls.Add call.


    ReplyBar.Controls.Add(xtpControlLabel, 12, "").Width = 2500   ' Arbitrary large number to force the next toolbar to be docked to right edge of form



-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: JasonG
Date Posted: 08 July 2008 at 12:57pm
You are the MAN!


Posted By: ijwelch
Date Posted: 08 July 2008 at 1:01pm
Rewind a moment.

Your latest code shows:
ReplyBar.EnableDocking xtpFlagHideWrap Or xtpFlagHideWrap
and
ReplyBar2.EnableDocking xtpFlagHideWrap Or xtpFlagHideWrap

this should be

ReplyBar.EnableDocking xtpFlagStretchedShared Or xtpFlagHideWrap
ReplyBar2.EnableDocking xtpFlagStretchedShared Or xtpFlagHideWrap


I pasted your original code into new form, added CommandsBars to form, added Picturebox and added Commandbars2 to picturebox. My suggestion then did exactly what you're looking for.

Can you try again like I did above? I'll redo and post sample if required.



Posted By: JasonG
Date Posted: 08 July 2008 at 1:04pm
The lines that said

ReplyBar.EnableDocking xtpFlagHideWrap Or xtpFlagHideWrap

Were actually caught and fixed since I posted the code. I changed them to your reccomendation, and it works perfectly. Thanks again.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net