[Gambas-user] Trouble removing menu item during run time

Willy Raets willy at ...2734...
Sat Dec 1 01:13:46 CET 2012


I have this piece of code (in a rather big project) that build op a menu
during run time in case AddOns get installed. Each installed AddOn gets
it own Menu Item upon installation for launching the AddOn. THis all
works like clockwork.

This is the code that creates the menu items for each Add On installed:

For iNdex = 1 To AddOnNumber
  hMenuItem = New Menu(hMenu) As "_MenuEvent"
  With hMenuItem
    .Name = "mnu" & AddOnName[iNdex]
    .Enabled = True
    .Caption = AddOnName[iNdex]
    .Text = AddOnName[iNdex] & "..."
    .Picture = Picture.Load(AddOnPath & "/" & AddOnName[iNdex] & ".png")
  End With
Next

Now I write code to remove the installed AddOns if users want to.
Removing is no problem and works well.

Only problem that remains is how to remove the menu item that starts the
AddOn during run time?

In my Subroutine Remove() the name of the AddOn menu item to be removed
is: "mnu" & AvailableName[Index]

AvailableName[Index] is the name of the AddOn that has been removed a
few lines of code before.

How do I remove this menu item? Any suggestions?

Thanks,

Willy






More information about the User mailing list