Simple tutorial: Part 1
This tutorial makes avery simple
wxWidgets program, and shows how to insert menus and dialogs. The
aim of the project is to make a window which can be
coloured
- Run wxhatch and choose the
compiler you have (Choose | Select external
Compiler)
- Choose File | New project
and select the drawing type. Use the combo box to give the project
a name, eg color1. By default the projects will be put in the
project directory under wxhatch.
- A skeleton code is produced which
can be compiled (Run | Make) and then executed
(Run|Run)
Add menu Items
- Change to the MenuZone window
(File | View menu, Ctrl-W) and add the base of a menu (Add menu
| New menu). Call it &File; as with other wxWidgets
programs the & indicates the hot key
- Now add a Menu item, Quit,
by using Add Menu | Add Item. If you forget the & then you can
right click on the menuzone replica of the menu and choose Change
menu properties
- Double Click the MenuZone replica
of Quit and you should be taken to the method body. Type the
response to the menu, in this case Close();
is appropriate
void
MyFrame::OnFileQuit (wxCommandEvent & WXUNUSED(event))
{
//Respond to menu here
Close() ;
}
- Add a second Menu (&Select)
containing the command &Color, and a third one (Help) with an
item labelled &About
- The
window should look like this (click for larger
view)
Next
wxHatch
Home 