Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - popupmenu aligned with button
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

popupmenu aligned with button

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


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Topic: popupmenu aligned with button
    Posted: 09 March 2005 at 5:42pm

In my application i have a main menu with button. The main menu is runtime loaded and updated.

I want to create and show at runtime a popupmenu when the user click on the buttons of the main menu. And I want it in the same coordinates of a standard submenu.

So far it's ok,i can create the main menu at form load and create and show the popupmenu at execute event of commandbars.

When i show popupmenu via showpopup method the popupmenu is popped on mouse position, but i want it displayed in the same coordinates as a standard submenu.

I think to use showpopup method with x,y position parameter, but how i can get the position of the button control on the main menu ?

Why we can't have left, top, width, height position of the button control ?

I hope someone can help.

Bye

Maurizio

 

 

 

SuperPippo
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 09 March 2005 at 7:18pm
If they are clicking on a button in the menu, why not make it a splitbutton popup instead?
Back to Top
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 4:11am

Escuse me, may be i am not so clear on my explanations.

I am evaluating the migration of my application from other gui products (activebar).

In my application all the menu (main menu and submenu) are runtime defined.

The Main menu is loaded on form load event but at this time i don't know if the item of the main menu link or not a submenu. So all my item are CommandbarButton object.

When the user click an item of main menu the application can start with specific procedure or can load and show a submenu. So to load a submenu i use a Popup object.

But the Popup show it self in the mouse coordinates, that is not the same position of a standard submenu defined as CommandBarPopup object.

To workaround this problem in activebar i use showpopup method with the x,y parameter, i can calculate the screen coordinates x,y to show popup with a simple function starting from the position (top, left) and dimension (width, heigth) properties of a button in the main menu.

But in XtremeCommandbar how can i know the position and dimension of a button ?

And if i can't, here is some other workaround to show the popup in the same coordinates of a standard CommandBarPopup object ?

In attachment i send a simple project to better explain the problem.

Thank you.

2005-03-10_040926_PopupMenu.zip

 

SuperPippo
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 8:34am
Ok, I think this is what you are looking for.  To be clear, you are looking to dynamically display a popup menu in the ActiveMenuBar?  I assume you want to show popups in the menubar and not in the ToolBars, if thats the case, then you would use a popup toolbar.

In the modified attached sample I display 3 different popup menus, 1 for each main menu item.  Notice that I changed the type to ControlPopup (If you don't like this then I think I might have a messy workaround).  The first 2 popup menus were created in the form load and I simply copy them when needed, the 3rd popup menu it created dynamically.  You can use either method.

2005-03-10_082839_PopupMenus.zip
Back to Top
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 2:50pm

Hi SuperMario,

thank you for the support, but my application structure is different.

1ST)

In your code you create at form load a main menu as follow:

    With CommandBars.ActiveMenuBar.Controls
        Set Control = .Add(xtpControlPopup, ID_MnuMain_1, "MnuMain&1")
        Control.Id = ID_MnuMain_1
        Control.CommandBar.Title = "PopupMenu1"
    End With

here the control type is xtpControlPopup.

In my code when i load the form i don't know if the control is xtpControlPopup or xtpControlButton. When the user click an item on main menu (ActiveMenuBar) my code scan some memory structure and only at this moment I really know if I have a submenu or if I must do something other.

 

2ND)

Your code load submenu at runtime in InitCommandsPopup event and the show of submenu it's automatically operated. The code show submenu and go further away....(the show of a submenu isn't modal).

In my code I must use a context menu via showpopup method as submenu because in this way the code stop execution and wait for user input (in other word the showpopup is modal).

The code in my sample it's fully working, the only problem is the position of submenu. But to have the correct position i need to know the position and dimension of the item on main menu, how can i get it ? Someother workaround ?

 

SuperPippo
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 2:59pm
To keep the menu open until the user makes a selection when displaying a popup menu you can change the CloseSubMenuOnClick property.

About the other problem.  All I can suggest is that you first use a ControlButton,  If you determine that a popup is needed, then you will need to remove the control button and insert a ControlPopup in the same location. 
Back to Top
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Posted: 11 March 2005 at 2:25am

Hi SuperMario,

thanks a lot for your time.

I have made a simple project following your guidelines.

In this project on form load i create a main menu with some block of control. Every block have a control button and a popup button. At startup only the controls button are visible.

When user click on a item (visible control button) on main menu i get the "execute" event and here I change the visible state of control button with the popup on the same block I created on form load.

I set the CloseSubMenuOnClick = false for the popup button and populate the popup with a control.

After all i call popup.execute method to open popup.

Following i put in the code a debug.print message to assure that the code stopped opening the popup and at last i reset the original visible status of control button and popup.

Well the code is not working as we hope!

1st) The CloseSubMenuOnClick have no effect. The code follow to be executed after the opening of the popup.

2nd) The popup itself it's not in correct position

3rd) If you click more and more on the same item on main menu the popup move it self to walk on screen.

So i think that only popup.showpopup stop code execution waiting for user selection. If you use popup.execute the code does not stop.

The 2nd and 3rd problem are linked to 1st, following the code after .execute i have the reset of visible status, but this reset comes when the popup is still on screen (the code does'nt stop) and i think that this reset give me 2nd and 3rd problem.

Some other ideas ?

Why we can't get a function like getwindowrect for the controlbutton ? I think with this i can solve everything.....

I send you my simple project in attachment.

Thank you.

2005-03-11_022239_popupmenus.ZIP

 

SuperPippo
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 15 March 2005 at 3:00pm
Sorry for the delayed response.

1.  You must set this for each control added to the popup.  For example, here is some modified code from the sample I posted earlier.

    Dim PopupMenu1 As CommandBarPopup
   
    Set PopupMenu1 = CommandBars.ActiveMenuBar.Controls.Add(xtpControlPopup, 0, "&File", -1, False)
    PopupMenu1.Visible = False
    PopupMenu1.Id = ID_MnuSub_1
    With PopupMenu1.CommandBar.Controls
        Set Control = .Add(xtpControlButton, ID_FILE_NEW, "&New", -1, False)
        Control.CloseSubMenuOnClick = False
        Set Control = .Add(xtpControlButton, ID_FILE_OPEN, "&Open", -1, False)
        Control.CloseSubMenuOnClick = False
         ................
    End With

I have attached a sample that I think is closer to what you want.  First click on the menu button to see it act like a normal button, then click the toggle button to see it act like a popup.  Repeat to switch back and forth.
2005-03-15_150026_Popups.zip
Back to Top
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2005 at 5:14am

Hi SuperMario,

thanks a lot for your time.

May be that I don't explain well my problem so I resume.

I have an old application that use ActiveBar from DataDynamics and i want to change ActiveBar with XtremeSuite. I want to change the activex but, if possible, i don't want to change the application architecture.

The application have a main menu, the buttons on the main menu can launch procedures or can drop down submenus. For the submenus the application create at runtime context menus and show it (showpopup). The context menu (submenu) are moved in the position of a standard submenu (shopopup x,y parameter) to give the user the look of a standard submenu.

Change context menu with standard submenu it's not applicable because the code of my application are tied for showpopup.  Showpopup stop the code execution and wait for user input, standard submenu or execute method don't. My application must wait the user input or crash.

The code must move on this path. Your code doesn't apply to me:

You have standard submenu showed with execute method and Control.CloseSubMenuOnClick = False. This stop the menu on the screen but don't stop the code execution, yes you have an exit sub after execute method but my applicaton haven't. The rigth way is to show the menu with showpopup method, the Control.CloseSubMenuOnClick must be true.

But with showpopup method i have this problem:

1) In ActiveBar i can get the position of a button on mainmenu and starting from this i can give to showpopup the rigth x,y parameter. In XtremeCommandBar i have not a GetWindowRect for the button on main menu. So how i can get the correct x,y ? In attachment i give you a modified release of my last code sample. Here i get the correct position with this workaround:

1st) show the submenu as a standard menu with execute method

2nd) call GetWindowRect to get the rigth x,y of the submenu

3rd) show again the submenu as a context menu with showpop x,y

Look at the code. This work but it' s not so good because the double show.

2) With this code when i click an item on submenu (context menu) i don't get an execute event!!! So my submenu are useless!!!

I hope that this long message can help.

Thank a lot.

Maurizio

 2005-03-21_051210_popupmenu3.zip

SuperPippo
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.156 seconds.