public static bool LockToProcess(Process process)
        {
            Pinvokes.RECT windowRect, clientRect;
            Pinvokes.GetWindowRect(process.MainWindowHandle, out windowRect);
            Pinvokes.GetClientRect(process.MainWindowHandle, out clientRect);

            int borderThickness    = ((windowRect.Right - windowRect.Left) - clientRect.Right) / 2;
            int topBorderThickness = (windowRect.Bottom - windowRect.Top) - clientRect.Bottom;

            Pinvokes.RECT lockPosition;
            lockPosition.Left   = windowRect.Left + borderThickness;
            lockPosition.Right  = clientRect.Right + windowRect.Left + borderThickness;
            lockPosition.Top    = windowRect.Top + topBorderThickness - borderThickness;
            lockPosition.Bottom = clientRect.Bottom + windowRect.Top + topBorderThickness - borderThickness;

            return(Pinvokes.ClipCursor(ref lockPosition));
        }