X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1bffa9138f96098a82ec635b3e8612b34f414796..a92b0cfd2bd0bef75b43c071df0b0e028f360d8e:/src/msw/app.cpp diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 31e9ddfc8a..c59675e7f6 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -45,9 +45,11 @@ #include "wx/dynarray.h" #include "wx/wxchar.h" #include "wx/icon.h" + #include "wx/log.h" #endif -#include "wx/log.h" +#include "wx/cmdline.h" +#include "wx/filename.h" #include "wx/module.h" #include "wx/msw/private.h" @@ -281,6 +283,7 @@ bool wxApp::Initialize() LOGBRUSH lb; lb.lbStyle = BS_PATTERN; + lb.lbColor = 0; lb.lbHatch = (int)LoadBitmap( wxhInstance, wxT("wxDISABLE_BUTTON_BITMAP") ); if ( lb.lbHatch ) { @@ -461,6 +464,7 @@ bool wxApp::UnregisterWindowClasses() { bool retval = TRUE; +#ifndef __WXMICROWIN__ // frame window class. if ( !UnregisterClass(wxFrameClassName, wxhInstance) ) { @@ -539,7 +543,8 @@ bool wxApp::UnregisterWindowClasses() retval = FALSE; } - +#endif + // __WXMICROWIN__ return retval; } @@ -547,73 +552,35 @@ bool wxApp::UnregisterWindowClasses() // Convert Windows to argc, argv style // --------------------------------------------------------------------------- -void wxApp::ConvertToStandardCommandArgs(char* lpCmdLine) +void wxApp::ConvertToStandardCommandArgs(const char* lpCmdLine) { - wxStringList args; - - wxString cmdLine(lpCmdLine); - int count = 0; - - // Get application name - wxChar name[260]; // 260 is MAX_PATH value from windef.h - ::GetModuleFileName(wxhInstance, name, WXSIZEOF(name)); - - args.Add(name); - count++; - - wxStrcpy(name, wxFileNameFromPath(name)); - wxStripExtension(name); - wxTheApp->SetAppName(name); - - // Break up string - // Treat strings enclosed in double-quotes as single arguments - int i = 0; - int len = cmdLine.Length(); - while (i < len) - { - // Skip whitespace - while ((i < len) && wxIsspace(cmdLine.GetChar(i))) - i ++; + // break the command line in words + wxArrayString args = + wxCmdLineParser::ConvertStringToArgs(wxConvertMB2WX(lpCmdLine)); - if (i < len) - { - if (cmdLine.GetChar(i) == wxT('"')) // We found the start of a string - { - i ++; - int first = i; - while ((i < len) && (cmdLine.GetChar(i) != wxT('"'))) - i ++; + // +1 here for the program name + argc = args.GetCount() + 1; - wxString arg(cmdLine.Mid(first, (i - first))); + // and +1 here for the terminating NULL + argv = new wxChar *[argc + 1]; - args.Add(arg); - count ++; + argv[0] = new wxChar[260]; // 260 is MAX_PATH value from windef.h + ::GetModuleFileName(wxhInstance, argv[0], 260); - if (i < len) - i ++; // Skip past 2nd quote - } - else // Unquoted argument - { - int first = i; - while ((i < len) && !wxIsspace(cmdLine.GetChar(i))) - i ++; + // also set the app name from argv[0] + wxString name; + wxFileName::SplitPath(argv[0], NULL, &name, NULL); - wxString arg(cmdLine.Mid(first, (i - first))); + SetAppName(name); - args.Add(arg); - count ++; - } - } - } - - wxTheApp->argv = new wxChar*[count + 1]; - for (i = 0; i < count; i++) + // copy all the other arguments to wxApp::argv[] + for ( int i = 1; i < argc; i++ ) { - wxString arg(args[i]); - wxTheApp->argv[i] = copystring((const wxChar*)arg); + argv[i] = copystring(args[i - 1]); } - wxTheApp->argv[count] = NULL; // argv[] is a NULL-terminated list - wxTheApp->argc = count; + + // argv[] must be NULL-terminated + argv[argc] = NULL; } //// Cleans up any wxWindows internal structures left lying around @@ -820,7 +787,8 @@ int wxEntry(WXHINSTANCE hInstance, wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") ); // save the WinMain() parameters - wxTheApp->ConvertToStandardCommandArgs(lpCmdLine); + if (lpCmdLine) // MicroWindows passes NULL + wxTheApp->ConvertToStandardCommandArgs(lpCmdLine); wxTheApp->m_nCmdShow = nCmdShow; // We really don't want timestamps by default, because it means