[Gambas-user] Event in Menu
Fabien BODARD
Gambasfr at ...11...
Thu Aug 14 17:46:37 CEST 2003
Le Jeudi 14 Août 2003 07:00, Rizky Tahara Shita a écrit :
> hi,
>
> i create a program that create a menu.. i create this menu not from the
> designer.. but from the coding, so when the program runs it will have the
> same structure menu...
>
> i just wanna ask.. how do i accessed the event click on that menu ???
> so when the menu that i create with coding works just like a menu that i
> designed in gui...
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
Has we says in french.... OULALA
So,
When you created your menu you type :
Private mnuQuit as Menu 'to store the menu.id's
Public Sub MenuCreating()
Dim hMenu as Menu
Dim MnuParent as Object
mnuParent = Me
hMenu = NewMenu(mnuParent) as "MnuFileEvent"
hMenu.Text = "File"
mnuQuit = NewMenu(hMenu) as "MnuQuitEvent"
' it's the as ... who define the events label !!
mnuQuit.Text = "Quit"
end
Public Sub MenuQuitEvent_Click()
QUIT
end
That's all
See the SupSelector.Class of the gambas IDE for more information about menu,
and menu container. For exemple, i can define a menu in the embedded windows
parent, and have the code event in the embedded window itself. As i can
remember this is not possible on vb...
Oh .. you can define more than one menu with the same event name... this made
a groupe.
For a group be carefull the better is to define a tag for each item.
Private mnuTab as Object[] 'to store the menu.id's
Private mnuFile as Menu
Public Sub MenuCreating()
Dim hMenu as Menu
Dim MnuParent as Object
mnuParent = Me
mnuFile = NewMenu(mnuParent) as "MnuFileEvent"
mnuFile.Text = "File"
hMenu = NewMenu(hMenu) as "MnuEvent"
hMenu.Text = "Open"
hMenu.Tag = mnuTab.Count
mnuTab.Add(hMenu)
hMenu = NewMenu(hMenu) as "MnuEvent"
hMenu.Text = "Quit"
hMenu.Tag = mnuTab.Count
mnuTab.Add(hMenu)
end
and in the event manager :
Public sub mnuEvent_Click()
Select Case LAST.Tag
Case 0
Dialog.OpenFile
mnuTab[Last.Tag].Enabled = False 'This switch the menu open to not enabled!
Case 1
QUIT
...
end
Fabien Bodard
More information about the User
mailing list