Skip to main content
GameDev.net gamedev.net
🔒 Locked

Windowed Mode Mouse Problem -- Solved

Started by Aiursrage2k Mar 31, 2006 at 9:35 AM 2 replies 1.3k views
Original Post
Aiursrage2k
Aiursrage2k
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]
Insufficent Information: we need more infromationhttp://staff.samods.org/aiursrage2k/
jollyjeffers
jollyjeffers
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
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
SpreeTree
SpreeTree
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]
Aiursrage2k
Aiursrage2k
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
Insufficent Information: we need more infromationhttp://staff.samods.org/aiursrage2k/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.