Jump to content
  • Advertisement
Sign in to follow this  
Aiursrage2k

Windowed Mode Mouse Problem -- Solved

This topic is 4587 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have created a small gui for my game, I am hiding windows mouse and drawing my own. The problem occurs in windowed mode, when I left click the mouse, the mouses true position might be in the task bar (rather then where my mouse is -- for example the middle of the screen). I can think a few ways to overcome this, none of which seem ideal: 1> Make sure the both mouse positions are the same. -- seems the best solution, but would prevent any differnt/intresting mouse movement. 2> Take total control of the mouse. 3> Simply not allow windowed mode. Note: For a while I thought my program was having major preformance issues, but it was just the stupid clicking. [Edited by - Aiursrage2k on April 1, 2006 9:20:39 AM]

Share this post


Link to post
Share on other sites
Advertisement
I'm not quite sure I see your problem here... I've got a windowed/fullscreen toggle on several applications and never had a problem with my rodent.

When the mouse moves outside of the windowed area it should reappear (if you use while(ShowCursor(FALSE)); to hide) as it'll only hide it for your window/application. In my applications the custom-drawn mouse just stops at the edge of the display which is exactly where the windows cursor reappears and the user can see exactly whats happened. Clicking outside the window will take focus from your application and you shouldn't even receive a message about a mouse-click.

One thing about the capturing of mice (and other similar resources) is that it's considered bad windowed-mode practice. Best practices and guidelines dictate that in Windowed mode you should always assume that the user might want to do something else - other applications might be running (even just a messenger client) that could interfere. Stopping the user doing what they want (by stealing the mouse) is more likely to irritate them [wink]

Jack

Share this post


Link to post
Share on other sites
This is a common problem, and it has many solutions, none of which are perfect.

Personally, I deal with it in two ways. When the window is in focus, I make sure the desktop mouse position is always at 0,0 (relative to my window, where 0,0 is the centre), which means my game cursor can move, but the desktop mouse never moves outside the scope of the window.

The, if the window loses focus (alt-tabbing usually), the desktop mouse can now move freely, allowing me to debug or do other things. When it gains focus, the desktop mouse locks back to 0,0.

I hope thats usefule to you, but as I said there are many different solutions, and people will prob present a few different ideas before you decide on a soltuion :)

Edit: Having just read jollyjeffers post, I can see what he means about it being annoying that you have stolen control of a cursor, but in my case, it is assumed the end product will always be full screen anyway.

Spree

[Edited by - SpreeTree on March 31, 2006 11:01:56 AM]

Share this post


Link to post
Share on other sites
I solved it by hiding the mouse and calling SetCursorPos(100,100) every frame. You can still alt tab (get your mouse back)... it works for me xD

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!