Print Page | Close Window

Sticky floating position?

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=14369
Printed Date: 06 November 2025 at 5:53am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sticky floating position?
Posted By: uiguy
Subject: Sticky floating position?
Date Posted: 23 May 2009 at 8:38am
My application allows the user to toggle individual toolbars between docked state and floating state.  I have implemented this by toggling the CommandBar's Position property between xtpBarFloating or xtpBarTop.  My problem is that the CommandBar does not remember its floating position. Consider these steps taken by the user:
 
- moves the floating toolbar to position 500, 600 on the screen
- docks the toolbar (via a dialog that sets Position to xtpBarTop)
- undocks the toolbar (via dialog that set the Position to xtpBarFloating)
- the toolbar is now position to the upper left portion of the screen, no where near the "last floating" position
 
Is there a remedy for this?  When the user undocks the toolbar via the dialog, I want it to show in the same position it was when it was last floating.
 



Replies:
Posted By: Mr.Den
Date Posted: 26 May 2009 at 12:59pm
Here is how I do it: (this works for me, your mileage may vary )
 
Put in the declarations of a form:
 
Private Const ID_BAR_TEST = 200
 
Create the command bar:

private sub SetUpCommandBars

Dim obBar As CommandBar

on error goto errHandler
   
    Set obBar = CommandBars.Add("Test Bar", xtpBarFloating)
    obBar.BarID = ID_BAR_TEST
   
    'add controls to bar
   
    CommandBars.DockToolBar obBar, 10, 800, xtpBarFloating
   
errHandler:
   
    If Err.Number Then
        MsgBox Err.Number & ", " & Err.Description, vbCritical , "SetUpCommandBars"
    End If
   
    Set obBar = Nothing

End Sub

Use this to move the Commandbar:
 
Private Sub TestDockToolBar()
 
Dim obBar As CommandBar
 
On Error GoTo errHandler
   
    For Each obBar In obCommandBars
       
        If obBar.BarID = ID_BAR_TEST Then
           
            obCommandBars.DockToolBar obBar, 900, 900, xtpBarFloating
           
        End If
       
    Next
   
errHandler:
   
    If Err.Number Then
        ShowErrorM Err.Number, Err.Description, "TestDockToolBar"
    End If
   
    Set obBar = Nothing
   
End Sub

You can change the hard coded numbers in the TestDockToolBar/DockToolBar command to variables that you set when changing from floating to docked, it should do what you need.

 Thanks to Aaron for giving me the tip on the DockToolBar function



-------------
Product: Xtreme SuitePro (ActiveX) version 16.3.1

Platform: Windows 7 Professional (64bit) - SP 1

Language: Visual Basic 6.0 SP 6



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