Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - RESOLVED: Positioning Help!! (Screenshot added)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

RESOLVED: Positioning Help!! (Screenshot added)

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


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Topic: RESOLVED: Positioning Help!! (Screenshot added)
    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






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

Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post 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)
  
Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post 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




Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post 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...
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 12:57pm
You are the MAN!
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post 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.
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.064 seconds.