mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Fix for BUG-2851, Windows 7 doesn't have the used API yet.
This commit is contained in:
parent
ce56ee1cb6
commit
24d4e926ad
1 changed files with 6 additions and 2 deletions
|
@ -114,6 +114,10 @@ namespace Greenshot.Base.Core
|
||||||
/// <returns>uint</returns>
|
/// <returns>uint</returns>
|
||||||
public static uint GetDpi(POINT location)
|
public static uint GetDpi(POINT location)
|
||||||
{
|
{
|
||||||
|
if (!WindowsVersion.IsWindows81OrLater)
|
||||||
|
{
|
||||||
|
return DefaultScreenDpi;
|
||||||
|
}
|
||||||
RECT rect = new RECT(location.X, location.Y, 1, 1);
|
RECT rect = new RECT(location.X, location.Y, 1, 1);
|
||||||
IntPtr hMonitor = User32.MonitorFromRect(ref rect, User32.MONITOR_DEFAULTTONEAREST);
|
IntPtr hMonitor = User32.MonitorFromRect(ref rect, User32.MONITOR_DEFAULTTONEAREST);
|
||||||
var result = GetDpiForMonitor(hMonitor, MonitorDpiType.EffectiveDpi, out var dpiX, out var dpiY);
|
var result = GetDpiForMonitor(hMonitor, MonitorDpiType.EffectiveDpi, out var dpiX, out var dpiY);
|
||||||
|
@ -172,7 +176,7 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hWnd">IntPtr</param>
|
/// <param name="hWnd">IntPtr</param>
|
||||||
/// <returns>uint with dpi</returns>
|
/// <returns>uint with dpi</returns>
|
||||||
[DllImport("User32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern uint GetDpiForWindow(IntPtr hWnd);
|
private static extern uint GetDpiForWindow(IntPtr hWnd);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -193,7 +197,7 @@ namespace Greenshot.Base.Core
|
||||||
/// Returns the system DPI.
|
/// Returns the system DPI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>uint with the system DPI</returns>
|
/// <returns>uint with the system DPI</returns>
|
||||||
[DllImport("User32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern uint GetDpiForSystem();
|
private static extern uint GetDpiForSystem();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue