Contents Up Previous Next

wxApp: wxObject

wxApp overview

The wxApp class represents the application itself.

wxApp::wxApp
wxApp::~wxApp
wxApp::argc
wxApp::argv
wxApp::wx_class
wxApp::work_proc
wxApp::Dispatch
wxApp::GetAppName
wxApp::GetClassName
wxApp::GetExitOnDelete
wxApp::GetPrintMode
wxApp::GetTopWindow
wxApp::ExitMainLoop
wxApp::Initialized
wxApp::MainLoop
wxApp::OnExit
wxApp::OnCharHook
wxApp::OnInit
wxApp::Pending
wxApp::ProcessMessage
wxApp::SetAppName
wxApp::SetClassName
wxApp::SetExitOnDelete
wxApp::SetPrintMode


wxApp::wxApp

void wxApp(int language = wxLANGUAGE_ENGLISH)

Constructor. Called implicitly with a definition of a wxApp object.

The argument is a language identifier; this is an experimental feature and will be expanded and documented in future versions.


wxApp::~wxApp

void ~wxApp(void)

Destructor. Will be called implicitly on program exit if the wxApp object is created on the stack.


wxApp::argc

int argc

Number of command line arguments (after environment-specific processing).


wxApp::argv

char ** argv

Command line arguments (after environment-specific processing).


wxApp::wx_class

char * wx_class

Currently used under Motif only, where the value is passed to XtOpenDisplay on initialization. Set this member in the constructor of your derived wxApp class to give the application a name other than the default "wxApp''.


wxApp::work_proc

void * work_proc

Set this member to the address of a function that takes a pointer to wxApp. It will be called whenever the system is idle and can be used to schedule background tasks.


wxApp::Dispatch

void Dispatch(void)

Dispatches the next event in the windowing system event queue. (MS Windows and Motif). See also wxApp::Pending.

This can be used for programming event loops, e.g.

  while (app.Pending())
    Dispatch();

wxApp::GetAppName

char * GetAppName(void)

Returns the application name. wxWindows sets this to a reasonable default before calling wxApp::OnInit, but the application can reset it at will.


wxApp::GetClassName

char * GetClassName(void)

Gets the class name of the application. The class name may be used in a platform specific manner to refer to the application.


wxApp::GetExitOnDelete

Bool GetExitOnDelete(void)

Returns TRUE if the application will exit when the top-level window is deleted, FALSE otherwise.


wxApp::GetPrintMode

Bool GetPrintMode(void)

Returns the print mode: see SetPrintMode.


wxApp::GetTopWindow

wxWindow * GetTopWindow(void)

Returns a pointer to the top window (as returned by wxApp::OnInit). This may return NULL if called before the end of wxApp::OnInit.


wxApp::ExitMainLoop

void ExitMainLoop(void)

Call this to explicitly exit the main message (event) loop. You should normally exit the main loop (and the application) by deleting the frame returned from wxApp::OnInit.


wxApp::Initialized

Bool Initialized(void)

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

int MainLoop(void)

Called by wxWindows on creation of the application. Override this if you wish to provide your own (environment-dependent) main loop.

Returns 0 under X, and the wParam of the WM_QUIT message under Windows.


wxApp::OnExit

int OnExit(void)

Provide this member function for any processing which needs to be done as the application is about to exit.


wxApp::OnCharHook

Bool OnCharHook(wxKeyEvent& ch)

This member is called (under Windows only) to allow the window to intercept keyboard events before they are processed by child windows. The default implementation forwards the message to the currently active window. The function should returns TRUE to indicate the character has been processed, or FALSE to allow default processing.

See also wxKeyEvent, wxEvtHandler::OnChar, wxEvtHandler::OnCharHook, wxDialogBox::OnCharHook.


wxApp::OnInit

wxFrame * OnInit(void)

This must be provided by the application, and must create and return the application's main window.


wxApp::Pending

Bool Pending(void)

Returns TRUE if unprocessed events are in the window system event queue (MS Windows and Motif). See also wxApp::Dispatch.


wxApp::ProcessMessage

Bool ProcessMessage(MSG *msg)

Windows-only function for processing a message. This function is called from the main message loop, checking for windows that may wish to process it. The function returns TRUE if the message was processed, FALSE otherwise. If you use wxWindows with another class library with its own message loop, you should make sure that this function is called to allow wxWindows to receive messages. For example, to allow co-existance with the Microsoft Foundation Classes, override the PreTranslateMessage function:

// Provide wxWindows message loop compatibility
BOOL CTheApp::PreTranslateMessage(MSG *msg)
{
  if (wxTheApp && wxTheApp->ProcessMessage(msg))
    return TRUE;
  else
    return CWinApp::PreTranslateMessage(msg);
}

wxApp::SetAppName

void SetAppName(char *name)

Sets the name of the application. The name may be used in dialogs (for example by the document/view framework). A default name is set by wxWindows.


wxApp::SetClassName

void SetClassName(char *name)

Sets the class name of the application. This may be used in a platform specific manner to refer to the application.


wxApp::SetExitOnDelete

void SetExitOnDelete(Bool flag)

If flag is TRUE (the default), the application will exit when the top-level frame is deleted. If FALSE, the application will continue to run.

Currently, setting this to FALSE only has an effect under Windows.


wxApp::SetPrintMode

void SetPrintMode(int mode)

Sets the print mode determining what printing facilities will be used by the printing framework.