From 392cde4282b0a965ca17cb5f4cdcc5fe1f687aa6 Mon Sep 17 00:00:00 2001 From: DavidXanatos Date: Sat, 5 Feb 2022 17:53:32 +0100 Subject: [PATCH] dpi fix --- CHANGELOG.md | 2 +- Sandboxie/core/svc/GuiServer.cpp | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e8d8b1..8280c0c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - fixed issue with box context menu in tray list [1106](https://github.com/sandboxie-plus/Sandboxie/issues/1106) - fixed issue with "AutoExec=..." - fixed issues canceling box deletion operations didn't working [1061](https://github.com/sandboxie-plus/Sandboxie/issues/1061) - +- fixed issue with DPI scalling and color picker dialog [#803](https://github.com/sandboxie-plus/Sandboxie/issues/803) diff --git a/Sandboxie/core/svc/GuiServer.cpp b/Sandboxie/core/svc/GuiServer.cpp index b429fe86..611bfd10 100644 --- a/Sandboxie/core/svc/GuiServer.cpp +++ b/Sandboxie/core/svc/GuiServer.cpp @@ -78,6 +78,14 @@ typedef struct _WND_HOOK { } WND_HOOK; +#ifndef _DPI_AWARENESS_CONTEXTS_ +struct DPI_AWARENESS_CONTEXT__ { int unused; }; +typedef DPI_AWARENESS_CONTEXT__ *DPI_AWARENESS_CONTEXT; +#endif +typedef DPI_AWARENESS_CONTEXT (WINAPI *P_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext); + +typedef BOOL (WINAPI *P_SetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT value); + //--------------------------------------------------------------------------- // Variables //--------------------------------------------------------------------------- @@ -85,14 +93,8 @@ typedef struct _WND_HOOK { static HWND DDE_Request_ProxyWnd = NULL; -#ifndef _DPI_AWARENESS_CONTEXTS_ -struct DPI_AWARENESS_CONTEXT__ { int unused; }; -typedef DPI_AWARENESS_CONTEXT__ *DPI_AWARENESS_CONTEXT; -#endif -typedef DPI_AWARENESS_CONTEXT (WINAPI *P_SetThreadDpiAwarenessContext)( - DPI_AWARENESS_CONTEXT dpiContext); - static P_SetThreadDpiAwarenessContext __sys_SetThreadDpiAwarenessContext = NULL; +static P_SetProcessDpiAwarenessContext __sys_SetProcessDpiAwarenessContext = NULL; //--------------------------------------------------------------------------- // Constructor @@ -124,6 +126,9 @@ GuiServer::GuiServer() __sys_SetThreadDpiAwarenessContext = (P_SetThreadDpiAwarenessContext)GetProcAddress( GetModuleHandle(L"user32.dll"), "SetThreadDpiAwarenessContext"); + + __sys_SetProcessDpiAwarenessContext = (P_SetProcessDpiAwarenessContext)GetProcAddress( + GetModuleHandle(L"user32.dll"), "SetProcessDpiAwarenessContext"); } @@ -567,6 +572,10 @@ void GuiServer::RunSlave(const WCHAR *cmdline) GuiServer *pThis = GetInstance(); + if (__sys_SetProcessDpiAwarenessContext) { + __sys_SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); + } + // // get process id for parent (which should be the main SbieSvc process) //