unknownSPY
unknownSPY

Reputation: 738

Is there any way in C++ windows code to stop a mouse moving oustide window bounds

I had a look and couldn't find any way apart from 3rd party programs. But is there any way through code (C++) that I can stop the cursor from being moved outside the bounds of the window? I have a FPS Game project on windows but obviously in windowed mode the mouce can be moved outside of the window which can then cause issues.

Upvotes: 0

Views: 1077

Answers (1)

alangab
alangab

Reputation: 867

Try ClipCursor:

CRect rect;
GetWindowRect(&rect);
ClipCursor(&rect);

Remember to release che Cursor with ClipCursor(NULL);

Upvotes: 0

Related Questions