Ejemplo n.º 1
0
        internal static void FindMaximumSingleMonitorRectangle(RECT windowRect, out RECT screenSubRect, out RECT monitorRect)
        {
            List <RECT> rects = new List <RECT>();

            NativeMethodsUltimate.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT rect, IntPtr lpData)
            {
                MONITORINFO mONITORINFO = default(MONITORINFO);
                mONITORINFO.cbSize      = (uint)Marshal.SizeOf(typeof(MONITORINFO));
                NativeMethodsUltimate.GetMonitorInfo(hMonitor, ref mONITORINFO);
                rects.Add(mONITORINFO.rcWork);
                return(true);
            }, IntPtr.Zero);
            long num = 0L;

            screenSubRect = new RECT
            {
                Left   = 0,
                Right  = 0,
                Top    = 0,
                Bottom = 0
            };
            monitorRect = new RECT
            {
                Left   = 0,
                Right  = 0,
                Top    = 0,
                Bottom = 0
            };
            foreach (RECT current in rects)
            {
                RECT rECT = current;
                RECT rECT2;
                NativeMethodsUltimate.IntersectRect(out rECT2, ref rECT, ref windowRect);
                long num2 = (long)(rECT2.Width * rECT2.Height);
                if (num2 > num)
                {
                    screenSubRect = rECT2;
                    monitorRect   = current;
                    num           = num2;
                }
            }
        }