Example #1
0
        internal static void FindMonitorRectsFromPoint(System.Windows.Point point, out Rect monitorRect, out Rect workAreaRect)
        {
            IntPtr intPtr = NativeMethodsUltimate.MonitorFromPoint(new POINT
            {
                X = (int)point.X,
                Y = (int)point.Y
            }, 2);

            monitorRect  = new Rect(0.0, 0.0, 0.0, 0.0);
            workAreaRect = new Rect(0.0, 0.0, 0.0, 0.0);
            if (intPtr != IntPtr.Zero)
            {
                MONITORINFO mONITORINFO = default(MONITORINFO);
                mONITORINFO.cbSize = (uint)Marshal.SizeOf(typeof(MONITORINFO));
                NativeMethodsUltimate.GetMonitorInfo(intPtr, ref mONITORINFO);
                monitorRect  = new Rect(mONITORINFO.rcMonitor.Position, mONITORINFO.rcMonitor.Size);
                workAreaRect = new Rect(mONITORINFO.rcWork.Position, mONITORINFO.rcWork.Size);
            }
        }