List all menus
Posted
#1
(In Topic #1265)
Regular

What is the best way to list all the menu items on a form?
Posted
Regular

Posted
Guru

Posted
Regular

Posted
Guru

bill-lancaster said
Thanks Bruce, but that lists only top menus and their immediate child menus, some of these could themselves have child menus and so on
Yes i know.
Did you want me to write the complete function for you? :roll:
Posted
Guru

Code (gambas)
- PrintMenu(hTopMenu)
- mc = m
- Do ' get menu path
- mc = mc.Parent
- sKeyPath = mc.Name &/ sKeyPath
- ' Print the current menu info
- PrintMenu(mc)
But I have no idea what you want to do with the info.
That's where you do your own coding.
Posted
Guru

Code (gambas)
This is some of the output from my program 'Screenhot"
{ MenuMain Menu
Text = Shortcut(("File"), "F")
Checked = True
{ MenuPrint Menu AllToolButtons
Name = "MenuPrint"
Text = Shortcut(("Print"), "P") & "…"
Picture = Picture["icon:/medium/print"]
Tag = "Menu"
Shortcut = "Ctrl+P"
{ MenuExit Menu AllToolButtons
Name = "MenuExit"
Text = Shortcut(("Exit"), "E")
Picture = Picture["icon:/medium/close"]
Tag = "Menu"
Shortcut = "Alt+F4"
{ MenuShot Menu
Text = Shortcut(("Screen shot"), "S")
{ MenuCapture Menu AllToolButtons
Name = "MenuCapture"
Text = Shortcut(("Capture"), "C")
Picture = Picture["icon:/medium/camera"]
Tag = "Menu"
Shortcut = "Ctrl+Shift+C"
Posted
Expert

You can set the menu item by 'block' or by text name. You can set multiple menu items buy sending each name separated by a comma.
example: The menu MyMenu contains the elements Menu1, Menu2, Menu3, Menu4.
Code (gambas)
Subroutine:
Code (gambas)
- TmpMnu.Enabled = InMode
- Else 'Set selected menus (by name) to the required mode.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Regular

Thank you once again.
Bill
Posted
Guru

If you use an absolute path to the .form file then the folder can not be moved unless you change the path in the code too.
Or If you use relative ./paths and then make a standalone .gambas executable archive file (not in the project folder) then the .form files are not included in the .gambas archive so that will also fail.
My method will be without any of those problems
Also my method will be "live/current"
Ie. Toggle/Radio menu Values will show as they are currently set not as they are initially configured.
and additional menus added by code will also be detected.
Posted
Regular

Posted
Regular

Howsomeever, I have a little mind experiment that may destroy both our theories. (Sorry, I've just been viewing a Brian Cox video and if you think you understand quantum physics then both you and I are mad.)
Suppose you have a custom component that is a menu… it isnt in the form nor is it in the menus…
Just to stick my tongue out, we have used such "virtual menu" components for years now. :-)
The are really cool for things like AboutMe's, SystemInfo's, and other things that we can just drag onto a form as a control with no code needed and yet when the proggie runs, woof! there is a menu item.
sleep now
b
1 guest and 0 members have just viewed this.

