raddebugger icon indicating copy to clipboard operation
raddebugger copied to clipboard

Scaling is broken on 150% with Windows 7

Open ghost opened this issue 11 months ago • 3 comments

image

I understand that this is not exactly a top priority issue, but the fix should be simple enough, as Windows 10 and 7 use only slightly different APIs to set DPI awareness.

ghost avatar Jan 14 '25 14:01 ghost

DPI awareness is in there. It's using the SetProcessDpiAwarenessContext API which may be too recent for your platform (looks like a Windows 7 desktop?).

Meanwhile, if you have the mouse pointer over a panel which isn't a text editor and ctrl+wheel you can scale the UI font size (which scales the UI). These are also available as settings under "Window Interface Settings".

leidegre avatar Jan 30 '25 08:01 leidegre

DPI awareness is in there. It's using the SetProcessDpiAwarenessContext API which may be too recent for your platform (looks like a Windows 7 desktop?).

Indeed, Windows 7 expects SetProcessDPIAware() to be called instead. This is how you set the DPI awareness for all 3 recent Windows versions:

void _set_dpi_awareness(void)
{
 // windows 10 1703
 HMODULE user32 = LoadLibrary(L"user32.dll");
 typedef BOOL (WINAPI* SetProcessDpiAwarenessContext_t)(DPI_AWARENESS_CONTEXT);
 SetProcessDpiAwarenessContext_t SetProcessDpiAwarenessContext = (void*)GetProcAddress(user32, "SetProcessDpiAwarenessContext");
 if (SetProcessDpiAwarenessContext != NULL)
  SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
 FreeLibrary(user32);
 // windows 8.1
 HMODULE shcore = LoadLibrary(L"shcore.dll");
 if (shcore != NULL)
 {
  typedef HRESULT (WINAPI* SetProcessDpiAwareness_t)(int);
  SetProcessDpiAwareness_t SetProcessDpiAwareness = (void*)GetProcAddress(shcore, "SetProcessDpiAwareness");
  if (SetProcessDpiAwareness != NULL)
   SetProcessDpiAwareness(2);
  FreeLibrary(shcore);
 }
 // windows 7
 SetProcessDPIAware();
}

ghost avatar Jan 30 '25 15:01 ghost

Or you can simply put this in manifest file and not write any code, zero logic or loading libraries needed - windows will do all of that for you automatically:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <asmv3:application>
    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

raddbg already uses manifest file - for common control visual styles, so this is just small extra to add there.

mmozeiko avatar Feb 06 '25 01:02 mmozeiko

Fixed in e6f53a39bb3fb946c4aeba0e9cd83bd9c81c5481

ryanfleury avatar May 20 '25 22:05 ryanfleury