private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam) { MainWindow.MINMAXINFO structure = (MainWindow.MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MainWindow.MINMAXINFO)); MainWindow.POINT pOINT = new MainWindow.POINT(); MainWindow.GetCursorPos(ref pOINT); IntPtr intPtr = MainWindow.MonitorFromPoint(pOINT, MainWindow.MonitorOptions.MONITOR_DEFAULTTONEAREST); if (intPtr != IntPtr.Zero) { MainWindow.MONITORINFO mONITORINFO = new MainWindow.MONITORINFO(); MainWindow.GetMonitorInfo(intPtr, mONITORINFO); MainWindow.RECT rECT = mONITORINFO.rcWork; MainWindow.RECT rECT1 = mONITORINFO.rcMonitor; structure.ptMaxPosition.x = Math.Abs(rECT.left - rECT1.left) - 7; structure.ptMaxPosition.y = Math.Abs(rECT.top - rECT1.top); structure.ptMaxSize.x = Math.Abs(rECT.right - rECT.left) + 14; structure.ptMaxSize.y = Math.Abs(rECT.bottom - rECT.top) + 7; } Marshal.StructureToPtr(structure, lParam, true); }
private static extern IntPtr MonitorFromPoint(MainWindow.POINT pt, MainWindow.MonitorOptions dwFlags);
private static extern bool GetCursorPos(ref MainWindow.POINT pt);