POINT p; GetClientRect(hwnd, &rcClip); p.x = rcClip.left; p.y = rcClip.top; ClientToScreen(hwnd, &p); OffsetRect(&rcClip, p.x, p.y); ClipCursor(&rcClip); ShowCursor(TRUE); ////////////////////////////// // The GetClientRect function retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner will be (0,0). // The ClientToScreen function replaces the client coordinates in the POINT structure with the screen coordinates. The screen coordinates are relative to the upper-left corner of the screen. // The OffsetRect function moves the specified rectangle by the specified offsets. // The ClipCursor function confines the cursor to a rectangular area on the screen. If a subsequent cursor position (set by the SetCursorPos function or the mouse) lies outside the rectangle, Windows automatically adjusts the position to keep the cursor inside the rectangular area.