views:

78

answers:

3

ok im setting a cursor in a loop it works but when i move the cursor it just changes back to the way it was. im using win32 api and i used

SetCursor(LoadCursor(hInstance, MAKEINTRESOURCE(IDC_PROTECTED)));
any idea

A: 

Yes. It is being changed by DefWindowProc().

if you want a different cursor over your window, use SetClassLong(), or, change the hCursor field of WNDCLASS when calling RegisterClass, if you are the one who's calling it youself

Pavel Radzivilovsky
im changing the cursor not when program starts when an event happenes
Ramiz Toma
@Ramiz: How does that contradict the suggestion to call SetClassLong() ? (Actually, you want `SetClassLongPtr(GCLP_HCURSOR)` for 64 bits compat, but that's a detail)
MSalters
+1  A: 

IIRC, you want to call SetCursor in response to WM_SETCURSOR. If memory serves, the cursor will also stay what you've set if the cursor member of the window class is set to NULL.

Jerry Coffin
i tried what you said but it didn't work
Ramiz Toma
Tried which -- setting the class cursor to NULL, or calling `SetCursor` in response to `WM_SETCURSOR`? In the latter case, you also need to return `TRUE` from the message handler. I just did a quick check of responding to `WM_SETCURSOR` and it worked quite nicely.
Jerry Coffin
when i register the window i have set it to my cursor but when it runs i see an hour glass cursor than when i set it to my other cursor it works. if i take out the WM_CURSOR the first cursor works but the second doesn't stay
Ramiz Toma
A: 

hi, may be you can try setcursor in WM_MOUSEMOVE.

fangzhzh
Very bad suggestion in terms of efficiency (laptop battery power, etc).
Pavel Radzivilovsky