Skip to content

Commit 5cc1116

Browse files
committed
feat: SetProcessDpiAwareness param
1 parent 29688e0 commit 5cc1116

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Wpf.Ui.Violeta/Win32/DpiAware.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@ public static class DpiAware
88
/// <summary>
99
/// <see cref="DisableDpiAwarenessAttribute"/>
1010
/// </summary>
11-
public static bool SetProcessDpiAwareness()
11+
/// <param name="awareness">
12+
/// <see cref="SHCore.PROCESS_DPI_AWARENESS.PROCESS_DPI_UNAWARE">0</see>
13+
/// <see cref="SHCore.PROCESS_DPI_AWARENESS.PROCESS_SYSTEM_DPI_AWARE">1</see>
14+
/// <see cref="SHCore.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE">2 (default)</see>
15+
/// </param>
16+
/// <returns></returns>
17+
public static bool SetProcessDpiAwareness(int awareness = (int)SHCore.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE)
1218
{
1319
if (NTdll.RtlGetVersion(out NTdll.OSVERSIONINFOEX osv) == NTdll.NTStatus.STATUS_SUCCESS)
1420
{
1521
Version osVersion = new(osv.MajorVersion, osv.MinorVersion, osv.BuildNumber, osv.PlatformId);
1622

1723
if (Environment.OSVersion.Platform == PlatformID.Win32NT && osVersion >= new Version(6, 3))
1824
{
19-
if (SHCore.SetProcessDpiAwareness(SHCore.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE) == 0)
25+
if (SHCore.SetProcessDpiAwareness((SHCore.PROCESS_DPI_AWARENESS)awareness) == 0)
2026
{
2127
return true;
2228
}

src/Wpf.Ui.Violeta/Win32/SHCore.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static class SHCore
88
public static extern uint SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness);
99

1010
[DllImport("shcore.dll")]
11-
public static extern int GetDpiForMonitor(nint hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
11+
public static extern int GetDpiForMonitor(nint hMonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
1212

1313
public enum PROCESS_DPI_AWARENESS
1414
{

0 commit comments

Comments
 (0)