Hi,
I am creating a puzzle game for Windows using SDL. So far everything went very
smoothly, but now I am stuck while trying to implement a colored mouse cursor.
I know that SDL officially only supports b/w cursors, but I do not require
cross-plattform compatibility, nor do I need hardware acceleration. So a
regular windows cursor will suffice. I would not want to hide the SDL cursor
and blit the mousecursor myself because that makes the mouse feel quite laggy
on slow systems.
So far I tried setting the mouse cursor via the windows API:
the following:
//load a windows cursor cursor resource
HCURSOR hCursor = (HCURSOR)LoadImage(NULL,CursorPath.c_str
(),IMAGE_CURSOR,0,0,LR_LOADFROMFILE|LR_SHARED);
//set the cursor globally.
::SetCursor(hCursor);
This works, but only for a brief moment, before SDL seems to notice what has
been happening and resets the cursor to the previous look.
I thought it might have to do with the following behaviour described in the
windows manual:
So I tried the following as well:
//Set the main window’s caption
SDL_WM_SetCaption(“MyGame”,"");
//get a handle to the main window
HWND MainWindowHandle=FindWindow(NULL,“MyGame”);
//set the window’s class cursor to NULL, so it does not revert
//to the sdl cursor as soon as the mouse is moving
SetClassLongPtr(MainWindowHandle,GCLP_HCURSOR,NULL);
//load a windows cursor cursor resource
HCURSOR hCursor = (HCURSOR)LoadImage(NULL,CursorPath.c_str
(),IMAGE_CURSOR,0,0,LR_LOADFROMFILE|LR_SHARED);
//set the cursor globally.
::SetCursor(hCursor);
Unfortunately this did not seem to have any different effect either.
Is there any kind of hack (again: I really don’t care about cross-plattform
compatibility at the moment) that would allow me to set a colored windows
cursor? I had a look at the SDL sources, but could not figure out how to do it.
Thanks,
Adrian Grigore