Print Page | Close Window

PopupMenu Alignment

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=514
Printed Date: 29 April 2024 at 10:49am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: PopupMenu Alignment
Posted By: amstel
Subject: PopupMenu Alignment
Date Posted: 11 March 2004 at 6:38am

How to center a popupmenu in a screen or align at a button ??

Thanks




Replies:
Posted By: SuperMario
Date Posted: 11 March 2004 at 7:27am
To center a popup menu on the screen you just pass in the x and y coordinantes of the screen to the CommandBars.ShowPopup method.  I believe this will only work for command bars of type xtpBarPopup, but I could be wrong.

         Set Popup = CommandBars.Add("Popup", xtpBarPopup)
        With Popup.Controls
         &nbs p;  .Add xtpControlButton, ID_FILE_NEW, "&New"
         &nbs p;  .Add xtpControlButton, ID_FILE_OPEN, "&Open"
         &nbs p;  .Add xtpControlButton, ID_FILE_SAVE, "&Save"
        End With
        Popup.ShowPopup  100, 100

Hope this helps.


Posted By: robs
Date Posted: 11 March 2004 at 8:04am

Also note that supplying the x,y is optional. If they are omitted, the popup will display at the current screen cursor position.

 



Posted By: amstel
Date Posted: 11 March 2004 at 11:06am

Ok, but coordinates is coordonates of the screen !!!

I want show a popupMenu in the form at coordinate of this form... It is possible ?



Posted By: amstel
Date Posted: 13 March 2004 at 9:00am
It's not possible ????


Posted By: robs
Date Posted: 13 March 2004 at 11:52am

amstel:

Paste this code in the DynamicPopus sample. Does it do what you would expect?

Private Sub frameChild_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim p As XtremeCommandBars.CommandBar
  Set p = CommandBars.Add("Test", xtpBarPopup)
  p.Controls.Add xtpControlButton, ID_FILE_OPEN, "Test"
 
  p.ShowPopup , X, Y
 
End Sub



Posted By: SuperMario
Date Posted: 13 March 2004 at 1:47pm
It appears that this method will only accept constant values as parameters.  Any time you pass in a value generated at runtime it will use the x and y coords of the mouse.  I did several tests and I have found no way to make this work.  It only appears to work in the MouseDown event because you expect the popup to be displayed where you clicked with the x and y passed to the event. But the values passed to the event do nothing in the showpopup method.   Try changing the value of x and y with a value stored in a variable, if you hard code it like x=100, that will work but that is no good at runtime.  But x=me.width will not work because it is not a constant.   I can think of a couple ugly workarounds, but it would be nice to pass in a variable as x and y.


Posted By: robs
Date Posted: 13 March 2004 at 2:20pm

SuperMario is right. I assumed that the x and y would come from a mouse event (as they normally are when showing a popup). I tried a bunch of workarrounds, but came up short so far.

 




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