#define DEBUG
#Include "inc/wx.bi"
Declare Function App_OnInit APICALL ( ) As wxBool
Declare Function App_OnExit APICALL ( ) As wxInt
Declare Sub MenuHandler APICALL (event As _wxEvent Ptr)

const FrameStyle =  wxSYSTEM_MENU _
                 or wxMINIMIZE_BOX _
                 or wxCAPTION _
                 or wxCLIP_CHILDREN _
                 or wxCLOSE_BOX

Dim Shared As _wxApp      Ptr App
Dim Shared As _wxFrame    Ptr Frame
Dim Shared As _wxCheckBox Ptr CheckBox


Sub EventListener APICALL (event As _wxEvent Ptr, iListener as wxInt)
  Select Case wxEvent_GetId( event )
    Case 1
      '' stuff for selecting item Check it from menu &Do goes here
      wxCheckBox_SetValue(CheckBox, WX_TRUE )
    Case 2
      '' stuff for selecting item Exit from menu &Do goes here
      wxWindow_close(Frame,WX_TRUE) 
    Case 3
      '' stuff for selecting item Uncheck it from menu &Undo goes here
      wxCheckBox_SetValue(CheckBox, WX_FALSE)
  End Select
End Sub

Function App_OnInit APICALL ( ) As wxBool
  Frame = wxFrame_ctor()
  wxFrame_Create(Frame,,,wxString("Menutest"),,,167,124,FrameStyle)
  wxEvtHandler_proxy(Frame, @EventListener)
  wxEvtHandler_Connect(Frame, wxEvent_EVT_COMMAND_MENU_SELECTED())
  
  Dim As _wxPanel Ptr Panel = wxPanel_ctor2(Frame)

  CheckBox = wxCheckBox_ctor( )
  wxCheckBox_Create(CheckBox,Panel,,wxString("CheckBox"),40,30)
  wxCheckBox_SetValue(CheckBox,0)

  Dim As _wxMenu Ptr Menu1 = wxMenu_ctor( wxString(""), 0 )
  wxMenuBase_Append(Menu1, 1, wxString("Check it"),wxString("Check it"),0)
  wxMenuBase_AppendSeparator( Menu1 )
  wxMenuBase_Append(Menu1, 2, wxString("Exit"), wxString("Exit"),0)

  Dim As _wxMenu Ptr Menu2 = wxMenu_ctor( wxString(""), 0 )
  wxMenuBase_Append(Menu2, 3, wxString("Uncheck it"),wxString("Uncheck it"),0)

  Dim As _wxMenuBar Ptr MenuBar = wxMenuBar_ctor()
  wxMenuBar_Append(MenuBar, Menu1, wxString("&Do") )
  wxMenuBar_Append(MenuBar, Menu2, wxString("&Undo") )
  wxFrame_SetMenuBar(Frame, MenuBar)

  wxWindow_Show(Frame)

  return  wxApp_OnInit( App )
End Function

Function App_OnExit APICALL ( ) As wxInt
  Return wxApp_OnExit( App )
End Function

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

