From 3384021ab17642d5ba74363f950d4e2506854839 Mon Sep 17 00:00:00 2001 From: "shahzaib.ibrahim" Date: Thu, 2 May 2024 16:31:28 +0200 Subject: [PATCH] Ticket#39: Adapt GetSystemMetrics call to be DPI dependent Writing GetSystemMetrics method in Widget class so that the child controls can use it to get System Metrics to be DPI dependent vi-eclipse/Eclipse-Platform#39 --- .../win32/org/eclipse/swt/widgets/Widget.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index 1fcf440f448..65d498b3430 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -2650,4 +2650,14 @@ void setZoom(int zoom) { private static void handleDPIChange(Widget widget, int newZoom, float scalingFactor) { widget.setZoom(newZoom); } + +int getSystemMetrics(int nIndex) { + if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607) { + return OS.GetSystemMetricsForDpi(nIndex, DPIUtil.mapZoomToDPI(getZoom())); + } else { + return OS.GetSystemMetrics(nIndex); + } +} + + }