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.
Related macros/global-functions group: Application and Process Management.
Functions | |
wxAppDerivedClass & | wxGetApp () |
This function doesn't exist in wxWidgets but it is created by using the wxIMPLEMENT_APP() macro. More... | |
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. More... | |
bool | wxInitialize () |
This function is used in wxBase only and only if you don't create wxApp object at all. More... | |
void | wxUninitialize () |
This function is for use in console (wxBase) programs only. More... | |
void | wxWakeUpIdle () |
This function wakes up the (internal and platform dependent) idle system, i.e. More... | |
bool | wxYield () |
Calls wxAppConsole::Yield if there is an existing application object. More... | |
bool | wxSafeYield (wxWindow *win=nullptr, bool onlyIfNeeded=false) |
Calls wxApp::SafeYield. More... | |
int | wxEntry (int &argc, wxChar **argv) |
This function initializes wxWidgets in a platform-dependent way. More... | |
int | wxEntry (HINSTANCE hInstance, HINSTANCE hPrevInstance=nullptr, char *pCmdLine=nullptr, int nCmdShow=SW_SHOWNORMAL) |
See wxEntry(int&,wxChar**) for more info about this function. More... | |
void | wxInitAllImageHandlers () |
Initializes all available image handlers. More... | |
bool | wxEntryStart (int &argc, wxChar **argv) |
This function can be used to perform the initialization of wxWidgets if you can't use the default initialization code for any reason. More... | |
bool | wxEntryStart (HINSTANCE hInstance, HINSTANCE hPrevInstance=nullptr, char *pCmdLine=nullptr, int nCmdShow=SW_SHOWNORMAL) |
See wxEntryStart(int&,wxChar**) for more info about this function. More... | |
void | wxEntryCleanup () |
Free resources allocated by a successful call to wxEntryStart(). More... | |
bool | wxInitialize (int argc=0, wxChar **argv=nullptr) |
Initialize the library (may be called as many times as needed, but each call to wxInitialize() must be matched by wxUninitialize()). More... | |
int wxEntry | ( | HINSTANCE | hInstance, |
HINSTANCE | hPrevInstance = nullptr , |
||
char * | pCmdLine = nullptr , |
||
int | nCmdShow = SW_SHOWNORMAL |
||
) |
See wxEntry(int&,wxChar**) for more info about this function.
Notice that the type of pCmdLine is char
*, even in Unicode build.
Include file:
#include <wx/app.h>
int wxEntry | ( | int & | argc, |
wxChar ** | argv | ||
) |
This function initializes wxWidgets in a platform-dependent way.
Use this if you are not using the default wxWidgets entry code (e.g. main or WinMain).
For example, you can initialize wxWidgets from a Microsoft Foundation Classes (MFC) application using this function.
Include file:
#include <wx/app.h>
void wxEntryCleanup | ( | ) |
bool wxEntryStart | ( | HINSTANCE | hInstance, |
HINSTANCE | hPrevInstance = nullptr , |
||
char * | pCmdLine = nullptr , |
||
int | nCmdShow = SW_SHOWNORMAL |
||
) |
See wxEntryStart(int&,wxChar**) for more info about this function.
This is an additional overload of wxEntryStart() provided under MSW only. It is meant to be called with the parameters passed to WinMain().
char
*, even in Unicode build.Include file:
#include <wx/init.h>
bool wxEntryStart | ( | int & | argc, |
wxChar ** | argv | ||
) |
This function can be used to perform the initialization of wxWidgets if you can't use the default initialization code for any reason.
If the function returns true, the initialization was successful and the global wxApp object wxTheApp has been created. Moreover, wxEntryCleanup() must be called afterwards. If the function returns false, a catastrophic initialization error occurred and (at least the GUI part of) the library can't be used at all.
Notice that parameters argc
and argv
may be modified by this function.
Include file:
#include <wx/init.h>
wxAppDerivedClass& wxGetApp | ( | ) |
This function doesn't exist in wxWidgets but it is created by using the wxIMPLEMENT_APP() macro.
Thus, before using it anywhere but in the same module where this macro is used, you must make it available using wxDECLARE_APP().
The advantage of using this function compared to directly using the global wxTheApp pointer is that the latter is of type wxApp* and so wouldn't allow you to access the functions specific to your application class but not present in wxApp while wxGetApp() returns the object of the right type.
Include file:
#include <wx/app.h>
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.
Notice that this function is only available if wxUSE_ON_FATAL_EXCEPTION
is 1 and under Windows platform this requires a compiler with support for SEH (structured exception handling) which currently means only Microsoft Visual C++.
Include file:
#include <wx/app.h>
void wxInitAllImageHandlers | ( | ) |
Initializes all available image handlers.
This function calls wxImage::AddHandler() for all the available image handlers (see Available image handlers for the full list). Calling it is the simplest way to initialize wxImage but it creates and registers even the handlers your program may not use. If you want to avoid the overhead of doing this you need to call wxImage::AddHandler() manually just for the handlers that you do want to use.
Include file:
#include <wx/image.h>
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 wxWidgets 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 either.
This function may be called several times but wxUninitialize() must be called for each successful call to this function.
Include file:
#include <wx/app.h>
bool wxInitialize | ( | int | argc = 0 , |
wxChar ** | argv = nullptr |
||
) |
Initialize the library (may be called as many times as needed, but each call to wxInitialize() must be matched by wxUninitialize()).
With this function you may avoid wxDECLARE_APP() and wxIMPLEMENT_APP() macros and use wxInitialize() and wxUninitialize() dynamically in the program startup and termination.
Include file:
#include <wx/init.h>
bool wxSafeYield | ( | wxWindow * | win = nullptr , |
bool | onlyIfNeeded = false |
||
) |
void wxUninitialize | ( | ) |
This function is for use in console (wxBase) programs only.
Clean up; the library can't be used any more after the last call to wxUninitialize().
It must be called once for each previous successful call to wxInitialize().
Include file:
#include <wx/app.h>
See wxInitialize() for more info.
Include file:
#include <wx/init.h>
void wxWakeUpIdle | ( | ) |
This function 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 file:
#include <wx/app.h>
bool wxYield | ( | ) |
Calls wxAppConsole::Yield if there is an existing application object.
Does nothing if there is no application (which typically only happens early during the program startup or late during its shutdown).
Include file:
#include <wx/app.h>