The wxApp class represents the application itself. A wxWindows application does not have a main procedure; the equivalent is the OnInit member defined for a class derived from wxApp. OnInit must create and return a main window frame as a bare minimum. If NULL is returned from OnInit, the application will exit. Note that the program's command line arguments, represented by argc and argv, are available from within wxApp member functions.
An application closes by destroying all windows. Because all frames must be destroyed for the application to exit, it is advisable to use parent frames wherever possible when creating new frames, so that deleting the top level frame will automatically delete child frames. In emergencies the wxExit function can be called to kill the application.
An example of defining an application follows:
class DerivedApp: public wxApp { public: wxFrame *OnInit(void); }; wxFrame *DerivedApp::OnInit(void) { wxFrame *the_frame = new wxFrame(argv[0]); ... return the_frame; } MyApp DerivedApp;
wxApp::wxApp
voidwxApp
Constructor. Call implicitly with a definition of a wxApp object.
wxApp::wxApp
voidwxApp
Destructor. Will be called implicitly if the wxApp object is created on the stack.
wxApp::argc
intargc
Number of command line arguments (after environment-specific processing).
wxApp::argv
char **argv
Command line arguments (after environment-specific processing).
wxApp::Initialized
BoolInitialized
Returns TRUE if the application has been initialized (i.e. if OnInit has returned successfully). This can be useful for error message routines to determine which method of output is best for the current state of the program (some windowing systems may not like dialogs to pop up before the main loop has been entered).
wxApp::MainLoop
voidMainLoop
Called by wxWindows on creation of the application. Override this if you wish to provide your own (environment-dependent) main loop.
wxApp::OnExit
voidOnExit
Provide this member function for any processing which needs to be done as the application is about to exit.
wxApp::OnInit
wxFrame *OnInit
This must be provided by the application, and must create and return the application's main window.