SetCursor from SetWindowsHookEx

  • Thread starter Thread starter Arsen V.
  • Start date Start date
A

Arsen V.

Hi,

Currently I am doing the following:

In my ChangeCursor() function
....
myHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)CallWndProc, NULL,
GetCurrentThreadId());
....

In my CallWndProc() function

LRESULT WINAPI CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (((CWPSTRUCT*)lParam)->message == WM_SETCURSOR)
{
// Change cursor
HCURSOR hCurs = LoadCursorFromFile("c:\\b.cur");
HCURSOR hPrevCurs = SetCursor(hCurs);
}
return CallNextHookEx(myHook, nCode, wParam, lParam);
}

When I test this, the cursor changes but constantly blinks and goes back to
the regular arrow.

When I debug and set a breakpoint in the //Change cursor section, I see that
program execution gets to this point. I also see that hCurs and hPrevCurs
get assigned not NULL values.

What am I doing wrong?

Thanks,
Arsen
 
Back
Top