Search code examples
user-interfacewxwidgets

What are the consequences of creating wxWidgets GUI components outside of OnInit?


Normally the GUI components are created in the OnInit-method. I noticed that it isn't actually necessary; you can create wxFrame outside the entire wxApp-object and it'll still work.

Are there any serious consequences?


Solution

  • Apparently you can construct wxFrame outside of the wxApp object by using the global method wxEntryStart.

    ::wxEntryStart 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 occured 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 files

    The only consequence of this seems to be that you should call wxEntryCleanup()