#Include "wx-c 0.9.2/wx.bi"

Declare Function App_OnInit WXCALL ( ) As wxBool
Declare Function App_OnExit WXCALL ( ) As wxInt

Declare Sub menuhandler WXCALL ( ByVal event As wxEvent Ptr, ByVal iListener As wxInt )

Dim Shared As wxApp Ptr wx_app
Dim Shared As wxFrame Ptr wx_frame
Dim Shared As wxPanel Ptr wx_panel

Function App_OnInit WXCALL ( ) As wxBool
	
	wx_frame = wxFrame_ctor( )
	wxFrame_Create( wx_frame, WX_NULL, -1, wxString_ctorUTF8("Menu - MultiLevel"), 440, 312, 400, 400, wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX Xor wxMAXIMIZE_BOX Xor wxRESIZE_BORDER, WX_NULL )
	wx_panel = wxPanel_ctor2( wx_frame, -1, -1, -1, -1, -1, 0, WX_NULL )
	
	
	'' create menus
	Dim As wxMenuBar Ptr wx_menubar
	wx_menubar = wxMenuBar_ctor( )
	
	
	'' menu "&Menu 0"
	Dim As wxMenu Ptr wx_menu0
	wx_menu0 = wxMenu_ctor( wxString_ctorUTF8(""), 0 )
	wxMenuBase_Append( wx_menu0, 1, wxString_ctorUTF8("item0"), wxString_ctorUTF8("item0"), 0 )
	wxMenuBase_Append( wx_menu0, 2, wxString_ctorUTF8("item1"), wxString_ctorUTF8("item1"), 0 )
		
		'' menu "submenuitem2"
		Dim As wxMenu Ptr wx_menu1
		wx_menu1 = wxMenu_ctor( wxString_ctorUTF8(""), 0 )
		wxMenuBase_Append( wx_menu1, 3, wxString_ctorUTF8("item0"), wxString_ctorUTF8("item0"), 0 )
	
	wxMenuBase_AppendSubMenu( wx_menu0, 4, wxString_ctorUTF8("submenuitem2"), wx_menu1, wxString_ctorUTF8("submenuitem2") )
	wxMenuBar_Append( wx_menubar, wx_menu0, wxString_ctorUTF8("&Menu 0") )
	
	'' menu "&Menu 2"
	Dim As wxMenu Ptr wx_menu2
	wx_menu2 = wxMenu_ctor( wxString_ctorUTF8(""), 0 )
	wxMenuBase_Append( wx_menu2, 5, wxString_ctorUTF8("item0"), wxString_ctorUTF8("item0"), 0 )
	wxMenuBase_AppendCheckItem( wx_menu2, 6, wxString_ctorUTF8("checkitem1"), wxString_ctorUTF8("checkitem1") )
	wxMenuBar_Append( wx_menubar, wx_menu2, wxString_ctorUTF8("&Menu 2") )
	wxFrame_SetMenuBar(wx_frame, wx_menubar)
	
	
	wxEvtHandler_Proxy( wx_frame, Cast(EventListener, @menuhandler) )
	wxEvtHandler_Connect( wx_frame, wxEvent_EVT_COMMAND_MENU_SELECTED( ), -1, -1, 0 )
	
	
	wxWindow_Show( wx_frame, 1 )
	wxApp_OnInit( wx_app )
	Return 1
	
End Function

Function App_OnExit WXCALL ( ) As wxInt
	
	Return wxApp_OnExit( wx_app )
	
End Function

Sub menuhandler WXCALL ( ByVal event As wxEvent Ptr, ByVal iListener As wxInt )
	
	Select Case wxEvent_GetId( event )
		Case 1
			'' stuff for selecting item item0 from menu &Menu 0 goes here
			
		Case 2
			'' stuff for selecting item item1 from menu &Menu 0 goes here
			
		Case 3
			'' stuff for selecting item item0 from menu submenuitem2 goes here
			
		Case 5
			'' stuff for selecting item item0 from menu &Menu 2 goes here
			
		Case 6
			'' stuff for selecting check item checkitem1 from menu &Menu 2 goes here
			
	End Select
	
End Sub


''main
wx_app = wxApp_ctor( )
wxApp_RegisterVirtual ( wx_app, @App_OnInit, @App_OnExit )
wxApp_Run(0, 0)
