Advertisement Jump to content
Sign in to follow this  

Windows custum cursor - new

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

Now I solved the former problem and can change cursors with: hCursor = LoadCursor(application.hInstance, MAKEINTRESOURCE(IDC_CURSOR4)); SetCursor(hCursor); But the problem is, after I change it, then when I move the mouse it changes back! What should I do? Thanks. [Edited by - daniel_i_l on August 10, 2006 5:37:13 PM]

Share this post

Link to post
Share on other sites
That's how SetCursor is supposed to work. You can fix that by changing cursor in your window class. But this is quite bad solution, since this will also change cursor for every window that has the same class.
Another (better) solution is to always reset cursor when it moves. For that, you can use WM_MOUSEMOVE message handler in your window proc. This has one advantage - you can test what is under your mouse and set cursor accordingly (e.g. if there's link under the cursor, use hand, otherwise use arrow).
Also, there's WM_SETCURSOR notification in which you can change cursor too.

if (useMyCursor)
return TRUE; // return true if you don't want to process this further
return FALSE;

Share this post

Link to post
Share on other sites
Setting the cursor in WM_MOUSEMOVE isn't a good idea, there's no guarantee that you won't get a WM_SETCURSOR first, which could cause Windows to switch to the default cursor then your cursor, causing flickering.

I always do this by setting the cursor in the window class - that's only a problem if you have multiple windows using the same window class (Which is rarely), and they all need different cursors (Which is pretty much never).

The proper place to se the cursor if you want to change cursor at runtime is in WM_SETCURSOR.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!