I am using SetCursor to set the system cursor to my own image. The code looks something like this:
// member on some class HCURSOR _cursor; // at init time _cursor = LoadCursorFromFile('somefilename.cur'); // in some function SetCursor(_cursor);
When I do this the cursor does change, but on the first mouse move message it changes back to the default system arrow cursor. This is the only code in the project that is setting the cursor. What do I need to do to make the cursor stay the way I set it?
It seems that I have two options. The first is the one that Mark Ransom suggested here, which is to respond to the windows
WM_SETCURSORmessage and call SetCursor at that time based on where the mouse is. Normally windows will only send youWM_SETCURSORwhen the cursor is over your window, so you would only set the cursor in your window.The other option is to set the default cursor for the window handle at the same time as I call
SetCursor. This changes the cursor set by the default handler toWM_SETCURSOR. That code would look something like this:If you use the second method you have to call both
SetCursorandSetClassLongor your cursor will not update until the next mouse move.