'this example demonstrate a wxFrame with buttons and checkboxes 'find the right checkbox with "dynamiccast" option explicit 'create id for buttons and checkboxes const ID_BUTTON1 = wxNewId(), ID_BUTTON2 = wxNewId(), ID_CHECKBOX1 = wxNewId(), ID_CHECKBOX2 = wxNewId() ' create the window dim frame = new wxFrame( nothing, -1, "wxBasic App", wxPoint( 10, 10 ), wxSize( 300, 220 ) ) frame.Centre() ' place a panel in the window dim panel = new wxPanel( frame, -1 ) ' add a status bar dim sBar = frame.CreateStatusBar( 1 ) sBar.SetStatusText("wxBasic Frame Demo") ' attach a menubar to the window dim mBar = new wxMenuBar() frame.SetMenuBar(mBar) ' build the "File" dropdown menu dim mFile = new wxMenu() mBar.Append(mFile, "&File") ' populate it mFile.Append( wxID_NEW, "&New", "Creates a new file" ) mFile.Append( wxID_OPEN, "&Open", "Loads an existing file from disk" ) mFile.Append( wxID_SAVE, "&Save", "Saves current file" ) mFile.Append( wxID_SAVEAS, "Save &As", "Saves current file with new name" ) mFile.AppendSeparator() mFile.Append( wxID_EXIT, "E&xit", "Exit Application" ) ' build the "Edit" dropdown menu dim mEdit = new wxMenu() mBar.Append(mEdit, "&Edit") mEdit.Append( wxID_CUT, "Cu&t", "Deletes selected text and copies it to buffer" ) mEdit.Append( wxID_COPY, "&Copy", "Copies selected text to buffer" ) mEdit.Append( wxID_PASTE, "&Paste", "Inserts buffer contents at current location" ) mEdit.Append( wxID_CLEAR, "Cl&ear", "Deletes selected text without copying to buffer" ) ' event handlers for the menus sub MenuNew( event ) handles frame.menuselected(wxID_NEW) wxMessageBox( "Menu: New Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub sub MenuOpen( event ) handles frame.menuselected(wxID_OPEN) wxMessageBox( "Menu: Open Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub sub MenuSave( event ) handles frame.menuselected(wxID_SAVE) wxMessageBox( "Menu: Save Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub sub MenuSaveAs( event ) handles frame.menuselected(wxID_SAVEAS) wxMessageBox( "Menu: Save As Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub sub MenuExit( event ) handles frame.menuselected(wxID_EXIT) wxMessageBox( "Menu: Exit Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) frame.Close(true) end sub sub MenuCut( event ) handles frame.menuselected(wxID_CUT) wxMessageBox( "Menu: Cut Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub sub MenuCopy( event ) handles frame.menuselected(wxID_COPY) wxMessageBox( "Menu: Copy Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub sub MenuPaste( event ) handles frame.menuselected(wxID_PASTE) wxMessageBox( "Menu: Paste Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub sub MenuClear( event ) handles frame.menuselected(wxID_CLEAR) wxMessageBox( "Menu: Clear Selected", "Menu Selection", wxOK + wxICON_INFORMATION, frame ) end sub ' add buttons dim Button = new wxButton( panel, ID_BUTTON1, "Button 1", wxPoint(10, 10) ) Button = new wxButton( panel, ID_BUTTON2, "Button 2", wxPoint(10, 40) ) 'handle button events sub ButtonPress( event ) handles frame.buttonclicked(ID_BUTTON1), frame.buttonclicked(ID_BUTTON2) dim id = event.GetId() dim text = iif(id = ID_BUTTON1, "Button1", "Button2") wxMessageBox( text &" Pressed", "Button Event", wxOK + wxICON_INFORMATION, frame ) end sub 'add checkboxes dim checkbox = new wxCheckBox( panel, ID_CHECKBOX1, "CheckBox 1", wxPoint(10, 70)) checkbox = new wxCheckBox( panel, ID_CHECKBOX2, "CheckBox 2", wxPoint(10, 110)) 'handle checkbox events sub CheckboxClicked( event ) handles frame.checkboxclicked(ID_CHECKBOX1), frame.checkboxclicked(ID_CHECKBOX2) 'get a pointer to the checkbox dim chk = DynamicCast("wxCheckbox", event.GetEventObject()) 'set the text dim text = iif(chk.GetId() = ID_CHECKBOX1, "Checkbox1", "Checkbox2") dim text2 = iif(chk.IsChecked(), "checked", "unchecked") wxMessageBox( text &" " &text2, "Checkbox event", wxOK + wxICON_INFORMATION, frame ) 'free the memory deallocate(chk) end sub ' show the window frame.Show(True)