wx.App Class Reference

Inheritance diagram for wx.App:

wx.EvtHandler wx.Object

List of all members.

Public Member Functions

virtual bool OnExceptionInMainLoop ()
virtual int OnExit ()
virtual void OnFatalException ()
virtual bool OnInit ()
void Run ()
bool SafeYield (Window win, bool onlyIfNeeded)
bool SafeYield (Window win)
bool SafeYield ()
bool Yield (bool onlyIfNeeded)
bool Yield ()

Static Public Member Functions

static App GetApp ()
static int GetLastOSError ()
static bool SetHandleFatalException (bool doIt)
static void WakeUpIdle ()

Public Attributes

event EventHandler OnExitEvent

Protected Member Functions

 App ()

Properties

string AppName [get, set]
bool IsActive [get]
bool IsMainLoopRunning [get]
static App TheApp [get]
string VendorName [get, set]


Detailed Description

The wxApp class represents the application itself. It is used to:

Constructor & Destructor Documentation

wx.App.App (  )  [protected]


Member Function Documentation

static App wx.App.GetApp (  )  [static]

static int wx.App.GetLastOSError (  )  [static]

This method is a helper for platform specific diagnostics. The method will return an error code directly from the operating system or other platform specific software. The resulting code is platform specific but 0 is guaranteed to mean "no error" or "this function is not supported".

The currently only supported platform is MS WINDOWS, where this return GetLastError().

Returns:
Error code or 0 if not error or not supported.

virtual bool wx.App.OnExceptionInMainLoop (  )  [virtual]

This function is called if an unhandled exception occurs inside the main application event loop. It can return true to ignore the exception and to continue running the loop or false to exit the loop and terminate the program. Warning: Do not throw an exception here.

The default behaviour of this function is the latter in all ports except under Windows where a dialog is shown to the user which allows him to choose between the different options. You may override this function in your class to do something more appropriate.

virtual int wx.App.OnExit (  )  [virtual]

Override this member function for any processing which needs to be done as the application is about to exit. OnExit() is called after destroying all application windows and controls, but before wxWidgets cleanup. Note that it is not called at all if OnInit() failed.

The return value of this function is currently ignored, return the same value as returned by the base class method if you override it.

virtual void wx.App.OnFatalException (  )  [virtual]

This function may be called if something fatal happens: an unhandled exception under Win32 or a a fatal signal under Unix, for example. However, this will not happen by default: you have to explicitly call SetHandleFatalExceptions() to enable this.

Generally speaking, this function should only show a message to the user and return. You may attempt to save unsaved data but this is not guaranteed to work and, in fact, probably won't.

The standard implementation does nothing.

virtual bool wx.App.OnInit (  )  [virtual]

This must be provided by the application, and will usually create the application's main window, optionally calling wx.App.SetTopWindow. You may use wx.App.OnExit to clean up anything initialized here, provided that the function returns true.

Notice that if you want to to use the command line processing provided by wxWidgets you have to call the base class version in the derived class OnInit().

Please note, that the STAThreadAttribute shall be set in threads running this. wxWidgets as well as .NET will conduct OLE initialization and these initializations must be done consistently.

Returns:
Return true to continue processing, false to exit the application immediately

void wx.App.Run (  ) 

bool wx.App.SafeYield ( Window  win,
bool  onlyIfNeeded 
)

This function is similar to wx.App.Yield(), except that it disables the user input to all program windows before calling wx.App.Yield and re-enables it again afterwards. If win is not NULL, this window will remain enabled, allowing the implementation of some limited user interaction.

Returns:
Returns the result of the call to wx.App.Yield().
Parameters:
win A top level window that will remain enabled or null.

bool wx.App.SafeYield ( Window  win  ) 

This function is similar to wx.App.Yield(), except that it disables the user input to all program windows before calling wx.App.Yield and re-enables it again afterwards. If win is not NULL, this window will remain enabled, allowing the implementation of some limited user interaction.

Returns:
Returns the result of the call to wx.App.Yield().
Parameters:
win A top level window that will remain enabled or null.

bool wx.App.SafeYield (  ) 

This function is similar to wx.App.Yield(), except that it disables the user input to all program windows before calling wx.App.Yield and re-enables it again afterwards. Returns the result of the call to wx.App.Yield().

static bool wx.App.SetHandleFatalException ( bool  doIt  )  [static]

Enable callback on fatal exceptions. Refer to OnFatalException().

static void wx.App.WakeUpIdle (  )  [static]

bool wx.App.Yield ( bool  onlyIfNeeded  ) 

Yields control to pending messages in the windowing system. This can be useful, for example, when a time-consuming process writes to a text window. Without an occasional yield, the text window will not be updated properly, and on systems with cooperative multitasking, such as Windows 3.1 other processes will not respond.

Caution should be exercised, however, since yielding may allow the user to perform actions which are not compatible with the current task. Disabling menu items or whole menus during processing can avoid unwanted reentrance of code: see wx.App.SafeYield for a better function.

Note that Yield() will not flush the message logs. This is intentional as calling Yield() is usually done to quickly update the screen and popping up a message box dialog may be undesirable. If you do wish to flush the log messages immediately (otherwise it will be done during the next idle loop iteration), call wx.Log.FlushActive.

Calling Yield() recursively is normally an error and an assert failure is raised in debug build if such situation is detected. However if the onlyIfNeeded parameter is true, the method will just silently return false instead.

bool wx.App.Yield (  ) 

cf. Yield(bool).


Member Data Documentation

event EventHandler wx.App.OnExitEvent

This will be called in the standard implementation of OnExit() before closing down the application.


Property Documentation

string wx.App.AppName [get, set]

Get or set the name of the application. Will be used e.g. to create keys in the hierarchy of registry entries.

bool wx.App.IsActive [get]

Returns true if the application is active, i.e. if one of its windows is currently in the foreground.

bool wx.App.IsMainLoopRunning [get]

Returns true if the main event loop is currently running, i.e. if the application is initialized and runs.

This can be useful to test whether the events can be dispatched. For example, if this function returns false, non-blocking sockets cannot be used because the events from them would never be processed.

App wx.App.TheApp [static, get]

Returns the application instance.

string wx.App.VendorName [get, set]

Name of the vendor. Will be used e.g. in the hierarchy of the Windows registry entries.


Manual of the wx.NET   (c) 2003-2011 the wx.NET project at   Get wx.NET at SourceForge.net. Fast, secure and Free Open Source software downloads