Sign in to follow this  

hide mouse cursor in fullscreen mode?

This topic is 2035 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 am trying to hide the Windows mouse cursor in fullscreen mode, and show it in Windows mode. What I have is working, except there is a delay (maybe 2 - 4 seconds). I can't figure out why.

When I go into fullscreen mode, I run the following code:

[CODE]
ShowCursor(FALSE);
SetCursor(NULL);
ClipCursor(&myWindowRect);[/CODE]

When I go into windowed mode, I run the following code:

[CODE]
ShowCursor(TRUE);
SetCursor(LoadCursor(NULL, IDC_ARROW));
ClipCursor(NULL);[/CODE]

I also check for the WM_SETCURSOR event, and I run one of the two blocks of code seen above, depending on whether I'm in fullscreen or windowed mode. When changing modes, there is a delay of 2 - 4 seconds.

Is there another Win32 API call I need to make? Is there another event I need to handle?

Share this post


Link to post
Share on other sites
Stupid question: does it hide the moment the cursor moves? Because as far as I know the cursor only gets updated the moment it's moved. A quick workaround for that would be to move the cursor to its current coordinates. The cursor stays in place, but it'll get updated anyways, which should hide it.

Share this post


Link to post
Share on other sites
Not a stupid question at all - the cursor hides/shows after about 2 - 4 seconds of movement. (i.e., after you switch to windowed/fullscreen mode, the mouse cursor disappears after 2 - 4 seconds of moving the mouse).

I will try moving the mouse cursor programmatically and see if that works.

Share this post


Link to post
Share on other sites
ShowCursor has a reference count. (Every time you call it with TRUE it increases the count, FALSE it decreases the count.) Make sure you aren't accidentally calling the windowed mode at program startup, or otherwise increasing you reference count unexpectedly.

Share this post


Link to post
Share on other sites
Also, how do you process your window messages? In a while loop to clear out the queue before updating again, or one per frame?

In the latter case the lag comes about from having too many messages in the queue.

Share this post


Link to post
Share on other sites
Maybe [i]SetCursor[/i] needs an explicit call to [i]ShowCursor[/i] (or a mouse related event) after it to have an effect? This thing often happens with [i]Set...[/i] functions.
Try commenting out all the[i] SetCursor[/i] function calls to see if it makes a difference. Edited by szecs

Share this post


Link to post
Share on other sites
[quote name='frob' timestamp='1337054793' post='4940281']
ShowCursor has a reference count. (Every time you call it with TRUE it increases the count, FALSE it decreases the count.) Make sure you aren't accidentally calling the windowed mode at program startup, or otherwise increasing you reference count unexpectedly.
[/quote]
If this was the case then the cursor state would remain stuck forever since there is no matching opposite call ShowCursor, right? (instead of fixing itself after a while)

Share this post


Link to post
Share on other sites
[quote name='Sik_the_hedgehog' timestamp='1337158110' post='4940627']
[quote name='frob' timestamp='1337054793' post='4940281']
ShowCursor has a reference count. (Every time you call it with TRUE it increases the count, FALSE it decreases the count.) Make sure you aren't accidentally calling the windowed mode at program startup, or otherwise increasing you reference count unexpectedly.
[/quote]
If this was the case then the cursor state would remain stuck forever since there is no matching opposite call ShowCursor, right? (instead of fixing itself after a while)
[/quote]
Not with indiscriminate usage. Often in novice's code they will repeatedly call ref-counted stuff without realizing the error. It will happen eventually with the next accidental call.

Share this post


Link to post
Share on other sites

This topic is 2035 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this