Application initialization and termination

The functions in this section are used on application startup/shutdown and also to control the behaviour of the main event loop of the GUI programs.

::wxEntry

This initializes wxWindows in a platform-dependent way. Use this if you are not using the default wxWindows entry code (e.g. main or WinMain). For example, you can initialize wxWindows from an Microsoft Foundation Classes application using this function.
void wxEntry(HANDLE hInstance, HANDLE hPrevInstance, const wxString& commandLine, int cmdShow, bool enterLoop = TRUE)
wxWindows initialization under Windows (non-DLL). If enterLoop is FALSE, the function will return immediately after calling wxApp::OnInit. Otherwise, the wxWindows message loop will be entered.
void wxEntry(HANDLE hInstance, HANDLE hPrevInstance, WORD wDataSegment, WORD wHeapSize, const wxString& commandLine)
wxWindows initialization under Windows (for applications constructed as a DLL).
int wxEntry(int argc, const wxString& * argv)
wxWindows initialization under Unix.

Remarks

To clean up wxWindows, call wxApp::OnExit followed by the static function wxApp::CleanUp. For example, if exiting from an MFC application that also uses wxWindows:
int CTheApp::ExitInstance()
{
  // OnExit isn't called by CleanUp so must be called explicitly.
  wxTheApp->OnExit();
  wxApp::CleanUp();
  return CWinApp::ExitInstance();
}

Include files

<wx/app.h>

::wxHandleFatalExceptions

bool wxHandleFatalExceptions(bool doIt = TRUE)
If doIt is TRUE, the fatal exceptions (also known as general protection faults under Windows or segmentation violations in the Unix world) will be caught and passed to wxApp::OnFatalException. By default, i.e. before this function is called, they will be handled in the normal way which usually just means that the application will be terminated. Calling wxHandleFatalExceptions() with doIt equal to FALSE will restore this default behaviour.

::wxInitAllImageHandlers

void wxInitAllImageHandlers()
Initializes all available image handlers. For a list of available handlers, see wxImage.

See also

wxImage, wxImageHandler

Include files

<wx/image.h>

::wxInitialize

bool wxInitialize()
This function is used in wxBase only and only if you don't create wxApp object at all. In this case you must call it from your main() function before calling any other wxWindows functions.
If the function returns FALSE the initialization could not be performed, in this case the library cannot be used and wxUninitialize shouldn't be called neither.
This function may be called several times but wxUninitialize must be called for each successful call to this function.

Include files

<wx/app.h>

::wxSafeYield

bool wxSafeYield(wxWindow* win = NULL, bool onlyIfNeeded = FALSE)
This function is similar to wxYield, except that it disables the user input to all program windows before calling wxYield 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 the result of the call to ::wxYield.

Include files

<wx/utils.h>

::wxUninitialize

void wxUninitialize()
This function is for use in console (wxBase) programs only. It must be called once for each previous successful call to wxInitialize.

Include files

<wx/app.h>

::wxYield

bool wxYield()
Calls wxApp::Yield.
This function is kept only for backwards compatibility. Please use the wxApp::Yield method instead in any new code.

Include files

<wx/app.h> or <wx/utils.h>

::wxWakeUpIdle

void wxWakeUpIdle()
This functions wakes up the (internal and platform dependent) idle system, i.e. it will force the system to send an idle event even if the system currently is idle and thus would not send any idle event until after some other event would get sent. This is also useful for sending events between two threads and is used by the corresponding functions ::wxPostEvent and wxEvtHandler::AddPendingEvent.

Include files

<wx/app.h>