Skip to content

Commit

Permalink
Fix: (simple) Windows 7 compatibility #5
Browse files Browse the repository at this point in the history
  • Loading branch information
LionelJouin committed Mar 18, 2019
1 parent 9687837 commit f87d796
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions PiP-Tool.Shared/Helpers/DpiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ public static class DpiHelper
/// <param name="dpiY">out dpi Y (vertical)</param>
public static void GetDpi(IntPtr hwnd, out float dpiX, out float dpiY)
{
var handle = NativeMethods.MonitorFromWindow(hwnd, MonitorDefaultTo.MONITOR_DEFAULTTONEAREST);
NativeMethods.GetDpiForMonitor(handle, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out var x, out var y);
try
{
var handle = NativeMethods.MonitorFromWindow(hwnd, MonitorDefaultTo.MONITOR_DEFAULTTONEAREST);
NativeMethods.GetDpiForMonitor(handle, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out var x, out var y);

dpiX = x / 96f;
dpiY = y / 96f;
dpiX = x / 96f;
dpiY = y / 96f;
}
catch (Exception)
{
dpiX = 1;
dpiY = 1;
}
}

/// <summary>
Expand Down

0 comments on commit f87d796

Please sign in to comment.