Example #1
0
        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

              const int monitorDefaulttonearest = 0x00000002;
              IntPtr monitor = NativeMethods.MonitorFromWindow(hwnd, monitorDefaulttonearest);

              if (monitor != IntPtr.Zero)
              {
            MONITORINFO monitorInfo = new MONITORINFO();
            NativeMethods.GetMonitorInfo(monitor, monitorInfo);

            RECT rcWorkArea = monitorInfo.rcWork;
            RECT rcMonitorArea = monitorInfo.rcMonitor;

            mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
            mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
            mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
            mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
              }

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