[Gambas-user] Problem with code made menu event handling

Willy Raets willy at ...2734...
Sun Oct 7 13:26:45 CEST 2012


On Sun, 2012-10-07 at 10:13 +0200, Fabien Bodard wrote:
> >> > >
> >> > > Public Sub _MenuEvent_Click()
> >> > >
> >> > >   Dim iX, iLength As Integer
> >> > >   Dim AddOnToRun As String
> >> >
> >> > When this is run, hMenuItem will be the last item you added, therefore
> >> > no matter how many Add-Ins you load only the last one will be run.
> >> > So you would need to find the menu item that was clicked and set
> >> > hMenuItem to that.
> >> >
> >> > >   iLength = Len(hMenuItem.Caption)
> >> > >   AddOnToRun = Left$(hMenuItem.Caption, (iLength - 3))
> >> > >   AddOnToRun = AddOnToRun & ".gambas"
> >> > >   Message(AddOnToRun)
> >> > >   AddOns.Run(AddOnToRun)
> >> > >
> >> > > End
> >>
> >> Couldn't you use 'Last' instead of hMenuItem in _MenuEvent_Click()?
> >>
Bruce, Tobian and Fabien,

Replaced hMenuItem with Last in event and all works well now

Public Sub _MenuEvent_Click()
  
  Dim iX, iLength As Integer
  Dim AddOnToRun As String
  iLength = Len(Last.Caption)
  AddOnToRun = Left$(Last.Caption, (iLength - 3))
  AddOnToRun = AddOnToRun & ".gambas"
  AddOns.Run(AddOnToRun)
  
End

Thanks you all very much,

Willy






More information about the User mailing list