Beispiel #1
0
        private void GetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            WinAPI.MINMAXINFO structure = (WinAPI.MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(WinAPI.MINMAXINFO));
            int    flags    = 2;
            IntPtr hMonitor = WinAPI.MonitorFromWindow(hwnd, flags);

            if (hMonitor != IntPtr.Zero)
            {
                WinAPI.MONITORINFO lpmi = new WinAPI.MONITORINFO();
                WinAPI.GetMonitorInfo(hMonitor, lpmi);
                WinAPI.RECT rcWork    = lpmi.rcWork;
                WinAPI.RECT rcMonitor = lpmi.rcMonitor;
                structure.ptMaxPosition.x  = Math.Abs((int)(rcWork.left - rcMonitor.left));
                structure.ptMaxPosition.y  = Math.Abs((int)(rcWork.top - rcMonitor.top));
                structure.ptMaxSize.x      = Math.Abs((int)(rcWork.right - rcWork.left));
                structure.ptMaxSize.y      = Math.Abs((int)(rcWork.bottom - rcWork.top));
                structure.ptMinTrackSize.x = (int)this.curwin.MinWidth;
                structure.ptMinTrackSize.y = (int)this.curwin.MinHeight;
            }
            Marshal.StructureToPtr(structure, lParam, true);
        }
Beispiel #2
0
 private void GetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
 {
     WinAPI.MINMAXINFO structure = (WinAPI.MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(WinAPI.MINMAXINFO));
     int flags = 2;
     IntPtr hMonitor = WinAPI.MonitorFromWindow(hwnd, flags);
     if (hMonitor != IntPtr.Zero)
     {
         WinAPI.MONITORINFO lpmi = new WinAPI.MONITORINFO();
         WinAPI.GetMonitorInfo(hMonitor, lpmi);
         WinAPI.RECT rcWork = lpmi.rcWork;
         WinAPI.RECT rcMonitor = lpmi.rcMonitor;
         structure.ptMaxPosition.x = Math.Abs((int)(rcWork.left - rcMonitor.left));
         structure.ptMaxPosition.y = Math.Abs((int)(rcWork.top - rcMonitor.top));
         structure.ptMaxSize.x = Math.Abs((int)(rcWork.right - rcWork.left));
         structure.ptMaxSize.y = Math.Abs((int)(rcWork.bottom - rcWork.top));
         structure.ptMinTrackSize.x = (int)this.curwin.MinWidth;
         structure.ptMinTrackSize.y = (int)this.curwin.MinHeight;
     }
     Marshal.StructureToPtr(structure, lParam, true);
 }