void HotKeyManager_RunXMove(object sender, MouseEventExtArgs e) { var hWnd = WinApi.WindowFromPoint(e.Location); var hParent = IntPtr.Zero; if (hWnd == IntPtr.Zero) { return; } while (true) { hParent = WinApi.GetParent(hWnd); if (hParent == IntPtr.Zero) { break; } hWnd = hParent; } if (!WinApi.IsWindow(hWnd)) { return; } WinApi.RECT r = new WinApi.RECT(); WinApi.GetWindowRect(hWnd, out r); offsetMoveWindow = new Point(e.X - r.Left, e.Y - r.Top); hWndMoveWindow = hWnd; isXMove = true; }