Results 1 to 6 of 6

Thread: Creating submenus at runtime

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    6

    Question

    Hi

    I have a popup menu on a system tray icon. One of the menu items opens a submenu listing some filenames in a directory.

    I'm looking to expand this to include folders within the directory, which will in turn expand into another submenu listing the files within those folders.

    See what I mean?!

    I can list the top-level files OK - this is done by creating a dummy submenu in the MenuEditor and programmatically adding to the menu's array. BUT how do I add another submenu to this array?

    I hope you understand what I mean )

    --
    Regards,

    Chris Platts

  2. #2
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274
    You can make an array of the submenu and use the following code to add more submenus at runtime.

    Code:
    Private Sub Form_Load()
    Dim I As Integer
    For I = 1 To 10
        Load mnuf(I)
    Next I
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    6

    Unhappy Thanks, but....

    Thanks for the help, but it's that bit I can already do )

    The problem is that I want to make one of the menus that I'm adding in this code open into *another* submenu.

    I've tried setting the Index property of one of the added menus to 0 (hence suggesting that it's a control array itself), but I get a 'Cannot change read-only property' error.

    Let me see if I can explain better with a picture

    I have the following menu:

    Item1
    Item2
    Item2SubItem1
    Item4


    Using code like that which you suggested, I can add menu items like so:

    Item1
    Item2
    Item2SubItem1
    Item2SubItem2
    Item2SubItem3
    Item4


    But what I want to do is this:


    Item1
    Item2
    Item2SubItem1
    Item2SubSubItem1
    Item2SubSubItem2
    Item2SubItem2
    Item2SubItem3
    Item4


    See what I mean?!

    The problem is that since these are intended to reflect folder & file lists, they have to be dinamically built at runtime. Which VB doesn't seem to be able to do, unless you define the submenus at design time. Which isn't suitable, since I don't know how manu submenus (i.e. folders) I'll be displaying....

    I've got a bad feeling this isn't possible in VB, but any ideas would be appreciated!

    --
    Regards,

    Chris Platts

  4. #4
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274
    I guess u'll have to make the menus using the windows api, which gives you the ability to change/design at runtime.

  5. #5
    Guest
    Take a look at this thread for creating menus with api.

  6. #6
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314
    Wasiq...


    Thanks for the menu tip!!

    Just what I was looking for.
    Steve Stunning

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