WinAPI – Moving the mouse cursor without triggering WM_MOUSEMOVE

I want to use SetCursorPos to capture the mouse in the middle of the window (just like in an FPS game).

The problem is that when I do this, My window will receive WM_MOUSEMOVE-this will at most cancel any movement the user wants, and at worst it will enter a feedback loop.

I considered using GetCursorPos to read the position and ignore the message, if it does Same position as I moved it with SetCursorPos. But the problem with this method is that the mouse is asynchronous. If the program lags, then GetCursorPos will return a different value than I expected-so it won’t know to ignore the message.

Is there a good way to deal with this problem?

When the application has focus, the RawInput API should be used to complete such input and hide the cursor. This It means that it is not limited by the screen, and you don’t actually handle mouse events.

I want to use SetCursorPos to capture the mouse in the middle of the window (just like in an FPS game).

The problem is that when I do this, my window will receive WM_MOUSEMOVE-this will at most cancel any movement the user wants, and at worst it will enter the feedback loop.

< p>I considered using GetCursorPos to read the position and ignore the message, if it is the same as the position I moved it with SetCursorPos. But the problem with this method is that the mouse is asynchronous. If the program lags behind, then GetCursorPos will return one with me Expect different values-so it won’t know to ignore the message.

Is there a good way to deal with this problem?

When the application has focus, you should use the RawInput API to complete such input and hide the cursor. This means that it is not restricted by the screen, and you actually don’t Do not handle mouse events.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4198 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.