public static IntPtr GetHMonitor(this Rectangle rect, MonitorDefaultTo defaultTo = MonitorDefaultTo.Nearest) { var nativeRect = new NativeRect() { Left = rect.Left, Top = rect.Top, Right = rect.Right, Bottom = rect.Bottom, }; return(MonitorFromRect(ref nativeRect, defaultTo)); }
public static Dpi GetMonitorDpi(this HwndSource hwndSource, MonitorDefaultTo defaultTo = MonitorDefaultTo.Nearest, MonitorDpiType dpiType = MonitorDpiType.Default) { var hmonitor = NativeMethods.MonitorFromWindow( hwndSource.Handle, defaultTo); uint dpiX = 1, dpiY = 1; NativeMethods.GetDpiForMonitor(hmonitor, dpiType, ref dpiX, ref dpiY); return new Dpi((ushort)dpiX, (ushort)dpiY); }
private static extern IntPtr MonitorFromPoint(Point pt, MonitorDefaultTo dwFlags);
public static extern IntPtr MonitorFromWindow(IntPtr hwnd, MonitorDefaultTo dwFlags);
internal static extern IntPtr MonitorFromWindow(IntPtr hWnd, MonitorDefaultTo dwFlags);
private static extern IntPtr MonitorFromRect([In] ref NativeRect lprc, [In] MonitorDefaultTo dwFlags);
private static extern IntPtr MonitorFromWindow([In] IntPtr hwnd, [In] MonitorDefaultTo dwFlags);
public static extern IntPtr MonitorFromPoint(System.Drawing.Point pt, MonitorDefaultTo dwFlags);
public static extern IntPtr MonitorFromRect(ref RECT lpRect, MonitorDefaultTo dwFlags);
public static extern IntPtr MonitorFromPoint(POINT pt, MonitorDefaultTo dwFlags);