[Gambas-user] dynamic created Menus

Karl Reinl karl.reinl at ...9...
Tue Feb 7 23:41:15 CET 2017


Am Montag, den 06.02.2017, 15:36 +0100 schrieb Fabien Bodard:
> I think the good way is this one :-)
> 
> Public Sub AddMenuFromOutsideForm(hMenu As Menu)
> Dim hMenuItem As Object
> Dim hParent As Object = Object.Parent(hMenu)
> 
>         hMenuItem = New Menu(hMenu)
>         hMenuItem = New Menu(hMenu)
>         Object.Attach(hMenuItem, hParent, "mnu_this_dont_work")
>         hMenuItem.Text = "this don't work"
>         hMenuItem = New Menu(hMenu)
>         Object.Attach(hMenuItem, hParent, "mnu_this_dont_work")
>         hMenuItem.Text = "this also don't work'"
> 
> End
> 
> 
> First find the class that handle menus events with object.parent on
> the given menu container.
> 
> then attach the new menu events to the same class instance with object.attach.
> 
> 2017-02-06 15:08 GMT+01:00 Charlie Reinl <Karl.Reinl at ...9...>:
> > Salut,
> >
> > how can I use dynamic created Menus, when they are made outside the
> > Form.
> > I expanded an example from Gianluigi to show what I want.
> > The problem is, the Click event is not fired, if the menu is not created
> > in the forms class.
> >

Salut,

Fabien, gave me a solution for my problem. But I do not understand why I
can attach Items to the menu, but not their events?
-- 
Amicalement
Charlie





More information about the User mailing list