Results 1 to 5 of 5

Thread: Form Menu hierarchy

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18
    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.

  2. #2
    Guest
    Please explain further, I do not quite understand

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18
    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.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I think there may be something in the API for this - I'll have a look.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    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
    {;->

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width