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

Bruce bbruen at ...2308...
Sat Dec 1 01:30:42 CET 2012


On Sat, 2012-12-01 at 01:13 +0100, Willy Raets wrote:
> 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
> 

(Quick answer)
You could just set its' .Visible to false

B






More information about the User mailing list