diff --git a/include/wx/msw/private/dpiaware.h b/include/wx/msw/private/dpiaware.h index 89165d00b4..122546df8a 100644 --- a/include/wx/msw/private/dpiaware.h +++ b/include/wx/msw/private/dpiaware.h @@ -15,6 +15,7 @@ #endif #include "wx/dynlib.h" +#include "wx/display.h" namespace wxMSWImpl { @@ -35,6 +36,9 @@ public: AutoSystemDpiAware() : m_prevContext(WXDPI_AWARENESS_CONTEXT_UNAWARE) { + if ( !Needed() ) + return; + if ( ms_pfnSetThreadDpiAwarenessContext == (SetThreadDpiAwarenessContext_t)-1) { wxLoadedDLL dllUser32("user32.dll"); @@ -62,6 +66,15 @@ public: } } + static bool Needed() + { + // use system-dpi-aware context when there are displays with different DPI + bool diferentDPI = false; + for ( unsigned i = 1; i < wxDisplay::GetCount() && !diferentDPI; ++i ) + diferentDPI = wxDisplay(0u).GetPPI() != wxDisplay(i).GetPPI(); + return diferentDPI; + } + private: WXDPI_AWARENESS_CONTEXT m_prevContext;