Jump to content

A function to lock mouse inside app window if it's active


Recommended Posts

Code snippet how i manage to do in in OpenGL loop

 if (hwnd == GetActiveWindow())
 {
     static RECT oldRect;
     RECT newRect;
     GetWindowRect(hwnd, &newRect);
     if (memcmp(&oldRect, &newRect, sizeof(RECT)) == 0) {
         ClipCursor(&newRect);
     }
     oldRect = newRect;
 }

 

  • Upvote 1
Link to comment
Share on other sites

What would you use this for? If the window is fullscreen, you have nothing to worry about. If the window is not fullscreen, you presumably want to be able to click on another window to select it.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Even with fullscreen cursor going out of window which can be annoying for moving camera by putting cursor near screen border in tactic and strategy games, I want to have it as an option game settings.

Link to comment
Share on other sites

If it's fullscreen, how can the cursor go outside the window?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...