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

Dim Shared As wxPanel Ptr panel
Dim Shared As wxTextCtrl Ptr textCtrl
Dim Shared As wxApp Ptr app

Sub EventHandler WXCALL ( event As wxEvent Ptr, iListener As wxInt )
  ' allocate a client DC
  Dim As wxDC Ptr dc = wxClientDC_ctor2(Panel)
  ' use it
  wxDC_Clear(dc)
  For i As Integer = 1 To 3
    wxDC_DrawCircle(dc, Rnd*640, Rnd*480, 1+Rnd*240)
  Next
  For i As Integer = 1 To 30
    wxDC_DrawLine(dc, Rnd*640, Rnd*480, Rnd*640, Rnd*480)
  Next
  For i As Integer = 1 To 10
    wxDC_DrawRotatedText(dc, wxString_ctorUTF8("Hello World!"), Rnd*640, Rnd*480, Rnd*360)
  Next
  ' release it
  wxDC_dtor(dc)
End Sub

Function OnInit WXCALL As wxBool
  Dim As wxFrame Ptr frame = wxFrame_ctor()
  wxFrame_Create(frame, WX_NULL, -1, wxString_ctorUTF8("wxClientDC"), -1, -1, 640, 480, _
               wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX _
               Xor wxMAXIMIZE_BOX Xor wxRESIZE_BORDER)
               
  panel = wxPanel_ctor2(frame, -1, -1, -1 , -1, -1 , 0, WX_NULL)
  
  Dim As _wxButton Ptr button = wxButton_ctor()
  wxButton_Create(button, panel, -1, wxString_ctorUTF8("click me"), 70, 270, 250, 60)
  wxEvtHandler_proxy(button, @EventHandler)
  wxEvtHandler_Connect(button, wxEvent_EVT_COMMAND_BUTTON_CLICKED(), -1, -1, 0)

  wxWindow_Show(frame,WX_TRUE)
  
  Return wxApp_OnInit(app)
End Function

Function OnExit WXCALL As wxInt
  Return wxApp_OnExit(app)
End Function

app = wxApp_ctor()
wxApp_RegisterVirtual(app, @OnInit, @OnExit)
wxApp_Run()


 