public static Screen FromPoint(Point point) { if (multiMonitorSupport) { var pt = new POINTSTRUCT((int)point.X, (int)point.Y); return(new Screen(MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST))); } return(new Screen((IntPtr)PRIMARY_MONITOR)); }
public static Screen FromPoint(System.Drawing.Point point) { if (multiMonitorSupport) { POINTSTRUCT pt = new POINTSTRUCT(point.X, point.Y); return(new Screen(MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST))); } else { return(new Screen((System.IntPtr)PRIMARY_MONITOR)); } }
public static IntPtr WindowFromPhysicalPoint(int x, int y) { POINTSTRUCT ps = new POINTSTRUCT(x, y); if (System.Environment.OSVersion.Version.Major >= 6) { return(IntWindowFromPhysicalPoint(ps)); } else { return(IntWindowFromPoint(ps)); } }
// [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto, Pack=4)] // public class MONITORINFOEX { // public int cbSize = Marshal.SizeOf(typeof(MONITORINFOEX)); // public RECT rcMonitor = new RECT(); // public RECT rcWork = new RECT(); // public int dwFlags = 0; // [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] // public char[] szDevice = new char[32]; // } public static void GetMonitorFromPosition(Point _position, out Screen _containingScreen, out IntPtr _hMonitor) { _containingScreen = null; _hMonitor = IntPtr.Zero; foreach (Screen screen in Screen.AllScreens) { if (screen.Bounds.Contains(_position)) { _containingScreen = screen; break; } } if (_containingScreen == null) { throw new Exception("Provided position is not contained by any monitor!"); } // Also retrieve the HMONITOR value POINTSTRUCT pt = new POINTSTRUCT(_position.X, _position.Y); _hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); }
/// <summary> /// Get the screen containing the given point. /// </summary> public static Screen FromPoint(Point point) { var nativePoint = new POINTSTRUCT((int)point.X, (int)point.Y); return new Screen(User32WindowFunctions.MonitorFromPoint(nativePoint, MONITOR_DEFAULTTO.NEAREST)); }
internal static extern int MapWindowPoints(HandleRef hWndFrom, HandleRef hWndTo, out POINTSTRUCT pt, int cPoints);
internal static extern bool GetCursorPos(out POINTSTRUCT pt);
private static extern IntPtr _ChildWindowFromPointEx(HandleRef hwndParent, POINTSTRUCT pt, int uFlags);
private static extern IntPtr _WindowFromPoint(POINTSTRUCT pt);
public static extern System.IntPtr MonitorFromPoint(POINTSTRUCT pt, int flags);
public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINTSTRUCT pptDst, ref NativeMethods.SIZESTRUCT psize, IntPtr hdcSrc, ref POINTSTRUCT pprSrc, int crKey, ref NativeMethods.BLENDFUNCTION pblend, int dwFlags);
public static extern HandleRef MonitorFromPoint(POINTSTRUCT pt, int flags);
public static extern IntPtr _WindowFromPoint(POINTSTRUCT pt);
public static IntPtr WindowFromPoint(int x, int y) { POINTSTRUCT pointstruct1 = new POINTSTRUCT(x, y); return _WindowFromPoint(pointstruct1); }
internal static extern IntPtr MonitorFromPoint(POINTSTRUCT pt, int flags);
public static IntPtr WindowFromPoint(int x, int y) { POINTSTRUCT ps = new POINTSTRUCT(x, y); return(_WindowFromPoint(ps)); }
public static extern IntPtr MonitorFromPoint(POINTSTRUCT pt, MonitorDefault flags);
private static extern IntPtr IntWindowFromPhysicalPoint(POINTSTRUCT pt);
public static IntPtr WindowFromPoint(int x, int y) { POINTSTRUCT ps = new POINTSTRUCT(x, y); return _WindowFromPoint(ps); }
public static IntPtr WindowFromPhysicalPoint(int x, int y) { POINTSTRUCT ps = new POINTSTRUCT(x, y); if (System.Environment.OSVersion.Version.Major >= 6) return IntWindowFromPhysicalPoint(ps); else return IntWindowFromPoint(ps); }
public static IntPtr ChildWindowFromPointEx(HandleRef hwndParent, int x, int y, int uFlags) { POINTSTRUCT ps = new POINTSTRUCT(x, y); return _ChildWindowFromPointEx(hwndParent, ps, uFlags); }
internal static IntPtr WindowFromPoint(Point p) { POINTSTRUCT ps = new POINTSTRUCT(p.X, p.Y); return(_WindowFromPoint(ps)); }
static extern IntPtr MonitorFromPoint(POINTSTRUCT pt, int flags);