Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Sticky floating position?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Sticky floating position?

 Post Reply Post Reply
Author
Message
uiguy View Drop Down
Newbie
Newbie


Joined: 22 May 2009
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote uiguy Quote  Post ReplyReply Direct Link To This Post Topic: Sticky floating position?
    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.
 
Back to Top
Mr.Den View Drop Down
Groupie
Groupie
Avatar

Joined: 26 August 2007
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mr.Den Quote  Post ReplyReply Direct Link To This Post 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
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.047 seconds.