Mark wx apps as DPI aware on Windows 7/Vista.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63990 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-04-16 10:22:45 +00:00
parent 07dc8f049e
commit 605ff820f5

View File

@@ -31,6 +31,7 @@
#endif //WX_PRECOMP
#include "wx/cmdline.h"
#include "wx/dynlib.h"
#include "wx/scopeguard.h"
#include "wx/msw/private.h"
@@ -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
// ----------------------------------------------------------------------------
@@ -381,6 +400,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;