+ wxAppInitializerFunction fnCreate = wxApp::GetInitializerFunction();
+
+ wxTheApp = (wxApp *)fnCreate();
+ }
+
+ wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") );
+
+ // app preinitialization
+ wxTheApp->argc = argc;
+
+#if wxUSE_UNICODE
+ wxTheApp->argv = new wxChar*[argc+1];
+ int mb_argc = 0;
+ while (mb_argc < argc)
+ {
+ wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
+ mb_argc++;
+ }
+ wxTheApp->argv[mb_argc] = (wxChar *)NULL;
+#else
+ wxTheApp->argv = argv;
+#endif
+
+ wxString name = wxFileNameFromPath(argv[0]);
+ wxStripExtension(name);
+ wxTheApp->SetAppName(name);
+
+ int retValue = 0;
+
+ // app initialization
+ if ( !wxTheApp->OnInit() )
+ retValue = -1;
+
+ // app execution
+ if ( retValue == 0 )
+ {
+ retValue = wxTheApp->OnRun();
+
+ // app clean up
+ wxTheApp->OnExit();
+ }
+
+ // library clean up
+ DoCleanUp();
+
+ return retValue;
+}
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+static bool DoInit()
+{
+ wxClassInfo::InitializeClasses();
+
+ wxModule::RegisterModules();
+ if ( !wxModule::InitializeModules() )
+ {
+ return FALSE;