X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/54705127970078c0cbce9f2ae76bc822acb0cf3c..b4607e897c31cd59c5ede98c3b5b5d3910902930:/src/msw/main.cpp diff --git a/src/msw/main.cpp b/src/msw/main.cpp index 17b5c1c88a..3e4338ee95 100644 --- a/src/msw/main.cpp +++ b/src/msw/main.cpp @@ -31,6 +31,7 @@ #endif //WX_PRECOMP #include "wx/cmdline.h" +#include "wx/dynlib.h" #include "wx/scopeguard.h" #include "wx/msw/private.h" @@ -120,7 +121,7 @@ void wxSETranslator(unsigned int WXUNUSED(code), EXCEPTION_POINTERS *ep) switch ( wxGlobalSEHandler(ep) ) { default: - wxFAIL_MSG( _T("unexpected wxGlobalSEHandler() return value") ); + wxFAIL_MSG( wxT("unexpected wxGlobalSEHandler() return value") ); // fall through case EXCEPTION_EXECUTE_HANDLER: @@ -154,19 +155,19 @@ bool wxHandleFatalExceptions(bool doit) wxChar fullname[MAX_PATH]; if ( !::GetTempPath(WXSIZEOF(fullname), fullname) ) { - wxLogLastError(_T("GetTempPath")); + wxLogLastError(wxT("GetTempPath")); // when all else fails... - wxStrcpy(fullname, _T("c:\\")); + wxStrcpy(fullname, wxT("c:\\")); } // use PID and date to make the report file name more unique wxString name = wxString::Format ( - _T("%s_%s_%lu.dmp"), + wxT("%s_%s_%lu.dmp"), wxTheApp ? (const wxChar*)wxTheApp->GetAppDisplayName().c_str() - : _T("wxwindows"), - wxDateTime::Now().Format(_T("%Y%m%dT%H%M%S")).c_str(), + : wxT("wxwindows"), + wxDateTime::Now().Format(wxT("%Y%m%dT%H%M%S")).c_str(), ::GetCurrentProcessId() ); @@ -203,6 +204,9 @@ int wxEntry(int& argc, wxChar **argv) #if wxUSE_GUI && defined(__WXMSW__) +namespace +{ + #if wxUSE_UNICODE && !defined(__WXWINCE__) #define NEED_UNICODE_CHECK #endif @@ -210,7 +214,7 @@ int wxEntry(int& argc, wxChar **argv) #ifdef NEED_UNICODE_CHECK // check whether Unicode is available -static bool wxIsUnicodeAvailable() +bool wxIsUnicodeAvailable() { static const wchar_t *ERROR_STRING = L"wxWidgets Fatal Error"; @@ -281,6 +285,21 @@ static bool wxIsUnicodeAvailable() #endif // NEED_UNICODE_CHECK +void wxSetProcessDPIAware() +{ +#if wxUSE_DYNLIB_CLASS + typedef BOOL (WINAPI *SetProcessDPIAware_t)(void); + wxDynamicLibrary dllUser32(wxT("user32.dll")); + SetProcessDPIAware_t pfnSetProcessDPIAware = + (SetProcessDPIAware_t)dllUser32.RawGetSymbol(wxT("SetProcessDPIAware")); + + if ( pfnSetProcessDPIAware ) + pfnSetProcessDPIAware(); +#endif // wxUSE_DYNLIB_CLASS +} + +} //anonymous namespace + // ---------------------------------------------------------------------------- // Windows-specific wxEntry // ---------------------------------------------------------------------------- @@ -314,8 +333,7 @@ struct wxMSWCommandLineArguments free(argv[i]); } - delete [] argv; - argv = NULL; + wxDELETEA(argv); argc = 0; } @@ -381,6 +399,13 @@ WXDLLEXPORT int wxEntry(HINSTANCE hInstance, wxCmdLineArgType WXUNUSED(pCmdLine), int nCmdShow) { + // wxWidgets library doesn't have problems with non-default DPI settings, + // so we can mark the app as "DPI aware" for Vista/Win7 (see + // http://msdn.microsoft.com/en-us/library/dd464659%28VS.85%29.aspx). + // Note that we intentionally do it here and not in wxApp, so that it + // doesn't happen if wx code is hosted in another app (e.g. a plugin). + wxSetProcessDPIAware(); + if ( !wxMSWEntryCommon(hInstance, nCmdShow) ) return -1;