X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8461e4c253d4cec65e8f0320246a56d22555eb5e..0adad2d72ffb322510e78ea366c58adbd1e8082e:/src/msw/app.cpp diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 45250cfe16..ea3044497a 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" @@ -124,7 +126,6 @@ // --------------------------------------------------------------------------- extern wxChar *wxBuffer; -extern wxList *wxWinHandleList; extern wxList WXDLLEXPORT wxPendingDelete; #ifndef __WXMICROWIN__ extern void wxSetKeyboardHook(bool doIt); @@ -192,9 +193,9 @@ END_EVENT_TABLE() bool wxApp::Initialize() { // the first thing to do is to check if we're trying to run an Unicode - // program under Win9x - if so, abort right now as it has no chance to - // work -#if wxUSE_UNICODE + // program under Win9x w/o MSLU emulation layer - if so, abort right now + // as it has no chance to work +#if wxUSE_UNICODE && !wxUSE_UNICODE_MSLU if ( wxGetOsVersion() != wxWINDOWS_NT ) { // note that we can use MessageBoxW() as it's implemented even under @@ -203,14 +204,14 @@ bool wxApp::Initialize() ::MessageBox ( NULL, - _T("This program uses Unicode and requires Windows NT/2000.\nProgram aborted."), + _T("This program uses Unicode and requires Windows NT/2000/XP.\nProgram aborted."), _T("wxWindows Fatal Error"), MB_ICONERROR | MB_OK ); return FALSE; } -#endif // wxUSE_UNICODE +#endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU // Some people may wish to use this, but // probably it shouldn't be here by default. @@ -282,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 ) { @@ -295,7 +297,7 @@ bool wxApp::Initialize() wxRegisterPenWin(); #endif - wxWinHandleList = new wxList(wxKEY_INTEGER); + wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100); // This is to foil optimizations in Visual C++ that throw out dummy.obj. // PLEASE DO NOT ALTER THIS. @@ -462,6 +464,7 @@ bool wxApp::UnregisterWindowClasses() { bool retval = TRUE; +#ifndef __WXMICROWIN__ // frame window class. if ( !UnregisterClass(wxFrameClassName, wxhInstance) ) { @@ -540,7 +543,8 @@ bool wxApp::UnregisterWindowClasses() retval = FALSE; } - +#endif + // __WXMICROWIN__ return retval; } @@ -548,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 @@ -701,8 +667,7 @@ void wxApp::CleanUp() Ctl3dUnregister(wxhInstance); #endif - if (wxWinHandleList) - delete wxWinHandleList; + delete wxWinHandleHash; // GL: I'm annoyed ... I don't know where to put this and I don't want to // create a module for that as it's part of the core. @@ -822,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