Example #1
0
        private static void WmGetMinMaxInfo(IntPtr hWnd, IntPtr lParam)
        {
            var mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
            IntPtr pMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
            if (pMonitor != IntPtr.Zero)
            {
                var mi = new MONITORINFO();
                GetMonitorInfo(pMonitor, mi);
                RECT rcWorkArea = mi.Work;
                RECT rcMonitorArea = mi.Monitor;
                mmi.MaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                mmi.MaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                mmi.MaxSize.X = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                mmi.MaxSize.Y = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
Example #2
0
 internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);