-
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 :))
-
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
-
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!
-
I guess u'll have to make the menus using the windows api, which gives you the ability to change/design at runtime.
-
Take a look at this thread for creating menus with api.
-
Wasiq...
Thanks for the menu tip!!
Just what I was looking for.