• Advertisement
Sign in to follow this  

Windows programming mouse cursor disappearing

This topic is 3293 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

Hi there, I'm doing a little Windows programming at the minute (Visual Studio 2005, C++) and I have a strange problem. I've create a window and have two CEdits in it for capturing input. Strangely, though, when I enter anything into these boxes, my mouse cursor will disappear if it is in that window. I can move it around and leave that window, and it will return to normal if the cursor moves into the main program window. Incidentally, the cursor also disappears in that window, but moving it at all will bring it back. I've read some stuff and tried the function which is... hmm... I think it's something like 'OnCursorChange' (it's a message handler, derived from CWnd). I tried to use the 'SetCursor' function to try and prevent something, but I'm not having any luck. I also tried overloading the 'OnKeyDown' function for the CEdit (I derived my own class so I could get the key down and cursor change functions), but had no luck. If anyone has any further clues, they would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Hiding the cursor when typing in an Edit control is actually standard Windows behaviour. There is a control panel option (Mouse, Pointer Options, Hide Pointer While Typing on my Win2k3 machine) which can toggle this on and off.

Share this post


Link to post
Share on other sites
Hm, interesting. Is there anyway I can do this in code, since if I want to give out a program or something, I'd rather not have to also give out such instructions.

Share this post


Link to post
Share on other sites
To be honest I don't see any way to "fight" the Windows setting without causing a nasty side effect, like a rapidly flashing cursor.

In any case, screwing with this is probably a bad idea. You need to assume that the end user either likes or dislikes this behaviour, and has their settings configured accordingly. You could technically fight it and try to keep the cursor visible, but it's generally considered good software etiquette to respect the user's configuration.

Out of sheer curiosity, why do you want this behaviour changed?

Share this post


Link to post
Share on other sites
The disappearing doesn't worry me too much, it's the fact that the one window is not consistent with the other and that the cursor disappears until I take it out of the window. That momentary disappearance I don't mind.

Share this post


Link to post
Share on other sites
Well, I shall have to come back. There are some security measures in place at my work place (yes, I've not been there too long). Nothing serious, but it might be tough for me to post actual code.

I'll write some stuff down sometime at work and come back. Hopefully you'll be around then and maybe this thread will have survived. If not, I'll try and contact you with a message or something.

It's really not that complicated though. I created a CWnd derived class (which only has some minor functionality to do with generic creation and some program specific non windows stuff) and added two CEdit derived boxes. The derivations were created because that was the only way I could get tabbing to work. Then, I added a function 'OnSetCursor' because the regular pointer changed to the sort of text input style cursor. I added this as a function to the window and the edit boxes. When I added that, that stopped the cursor changing, and it all works fine, except for when you type in the edit boxes and then move the mouse. I think it had that problem before I added that message handler. I'm sure enough messing around with it will present a solution, but obviously I would prefer to save that time.... etc.

Anyway, thanks for the help so far. It's been useful.

Share this post


Link to post
Share on other sites
Unfortunately, without actual code, or at least a minimal reproduction of the basic issue, there's not much more I can think of. Someone else might have some ideas, though.

Oh, and if you need to come back to the thread at a later date to post new information, go right ahead - the archive goes back pretty far [wink]

Share this post


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

  • Advertisement