static void GetDpi(Int32 x, Int32 y, MONITOR_DPI_TYPE dpiType, out UInt32 dpiX, out UInt32 dpiY) { var point = new System.Drawing.Point(x + 1, y + 1); IntPtr mon = MonitorFromPoint(point, MONITOR_POINT.MONITOR_DEFAULTTONEAREST); GetDpiForMonitor(mon, dpiType, out dpiX, out dpiY); }
/// <summary> /// Queries the dots per inch (dpi) of a display. /// </summary> /// <param name="hmonitor">Handle of the monitor being queried.</param> /// <param name="dpiType">The type of DPI being queried</param> /// <returns>The value of the DPI.</returns> public static int GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType = MONITOR_DPI_TYPE.MDT_DEFAULT) { if (IsPlatformSupported) { uint dpiX = 0; uint dpiY = 0; if (NativeMethods.GetDpiForMonitor(hmonitor, dpiType, ref dpiX, ref dpiY).Succeeded) { return((int)dpiX); } } return(DefaultDPI); }
/// <summary> /// Queries the dots per inch (dpi) of a display. /// </summary> /// <param name="hmonitor">Handle of the monitor being queried.</param> /// <param name="dpiType">The type of DPI being queried</param> /// <returns>The value of the DPI.</returns> public static int GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType = MONITOR_DPI_TYPE.MDT_DEFAULT) { if (IsPlatformSupported) { uint dpiX = 0; uint dpiY = 0; if (NativeMethods.GetDpiForMonitor(hmonitor, dpiType, ref dpiX, ref dpiY).Succeeded) { return (int)dpiX; } } return DefaultDPI; }
public static extern int GetDpiForMonitor( IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, ref uint dpiX, ref uint dpiY);
private static extern int GetDpiForMonitor( IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
public static extern HResult GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out int dpiX, out int dpiY);
/// <summary> /// Queries the dots per inch (dpi) of a display containing a window. /// </summary> /// <param name="hWnd">Handle of the window.</param> /// <param name="dpiType">The type of DPI being queried</param> /// <returns>The value of the DPI.</returns> public static int GetDpiForWindow(IntPtr hWnd, MONITOR_DPI_TYPE dpiType = MONITOR_DPI_TYPE.MDT_DEFAULT) { var hmonitor = User32.MonitorFromWindow(hWnd, MonitorOption.MONITOR_DEFAULTTONEAREST); return(GetDpiForMonitor(hmonitor, dpiType)); }
private static extern long GetDpiForMonitor( IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, ref uint dpiX, ref uint dpiY);
private static extern int GetDpiForMonitor([In] IntPtr hmonitor, [In] MONITOR_DPI_TYPE dpiType, [Out] out uint dpiX, [Out] out uint dpiY);
internal static extern IntPtr GetDpiForMonitor(IntPtr hMonitor, MONITOR_DPI_TYPE dpiType, ref UInt32 dpiX, ref UInt32 dpiY);
/// <summary> /// Queries the dots per inch (dpi) of a display containing a window. /// </summary> /// <param name="hWnd">Handle of the window.</param> /// <param name="dpiType">The type of DPI being queried</param> /// <returns>The value of the DPI.</returns> public static int GetDpiForWindow(IntPtr hWnd, MONITOR_DPI_TYPE dpiType = MONITOR_DPI_TYPE.MDT_DEFAULT) { var hmonitor = User32.MonitorFromWindow(hWnd, MonitorOption.MONITOR_DEFAULTTONEAREST); return GetDpiForMonitor(hmonitor, dpiType); }
public static extern HRESULT GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, ref uint dpiX, ref uint dpiY);
public static extern void GetDpiForMonitor(IntPtr hMonitor, MONITOR_DPI_TYPE dpiType, out int dpiX, out int dpiY);
internal static extern uint GetDpiForMonitor(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
internal static extern HRESULT GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out UInt32 dpiX, out UInt32 dpiY);
public static extern long GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
static extern IntPtr GetDpiForMonitor([In] IntPtr hmonitor, [In] MONITOR_DPI_TYPE dpiType, [Out] out UInt32 dpiX, [Out] out UInt32 dpiY);
public static extern HRESULT GetDpiForMonitor(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
public static extern long GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
public static extern HResult GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out int dpiX, out int dpiY);