-
Can anyone tell me how to get information about menu hierarchy of a vb form at run time. All i could do is get all the menu items by using for each control in form1.controls.. method but is there a way to find what a menu item has relation with other.
-
Please explain further, I do not quite understand
-
OK, i simply created menu using vb menu editor. first item is &File(mnuFile) and other items are &New(mnuFileNew) and &Open(mnuFileOpen) that come under &File(mnuFile). How can know at run time which menus comes under &File(mnuFile). And how can I get the parent (mnuFile) of mnuFileNew. All I could do so far is scan all controls of the forms for type as Menu, but there is no other information.
-
I think there may be something in the API for this - I'll have a look.
-
A manual way of doing it could be implemented by using the TAG property to mark each level, and if the first menu and submenus are 1 to 9 then the second menu and ITS submenus could be 10 to 19 and the third could be 20 to 29 etc etc
Code:
'So on file a file menu and edit menu - for example...
File
New File
Open File
Close File
Edit
Cut
Copy
Paste
'you could set the tag properties as..
File '1
New File '1/0
Open File '1/1
Close File '1/2
Edit '10
Cut '10/0
Copy '10/1
Paste '10/2
I've used a backslash to sepearate the parent menu from the child menu
Which means no backslash = Top level menu
1 backslash = level 1 submenu
2 backslash's = level 2 submenu
etc etc etc
All thats required is a little routine to read (and if you want - write) the TAG property.
Its may not be the best way but its logical and makes use of an already existing property, so therefore does not add (too much) to your exe's final size.
DocZaf
{;->