Help with menu please

Hello all,

Working with 2022R3.1 on a desktop app.

I want to click on an object and have a menu come up that the user can select from. One thing I do not want, is to have the menu be visible and/or part of the window menu.

To test and try to understand how to do this, I did add an new menu item in the designer.

Simple code
Var m As MenuItem
m = ManualControls_Map.PopUp // mnufile.PopUp

The problem(s) with this approach is that
1 The item is part of a bigger list, which is not what I was looking for, but as a test it was good.
2 The item is visible from the windows menu bar/sub menu which is not what I was wanting.

When I tried creating a new menu from the menu bar, even with the visible property set to not visible at design time, at run time it IS visible!

What is the correct/best way to do this?

Thanks all!
Tim

Make a menu in code and call pop up on that.

Dim m as new DesktopMenuItem

m.add new DesktopMenuItem("one")

Dim sel as DesktopMenuItem = m.popup

Thanks Greg!

That gets it started, but where to add the menu handler so code can be written to do something?

Edit is this the same as a ContextualMenu?

When is it appropriate to use either a DesktopMenuItem Vs a ContextualMenu?

Thanks again!
Tim

Popup returns the menu item that was selected. Or nil if no selection. So you call popup and then do a select case to respond to the item selected.

1 Like

That’s really great!

Thank you Tim!
Tim

you can use the tag/name propertie to put a name there to identify this menu item in a select case.

.Text
.Name
.Tag
in the tag you can also store a object.

Constructor have optional tag
Constructor(Text As String, [Tag As Variant])

the menu caption will have multilingual ability.

Thank you everyone!
Tim