Original Post
I''m using MVC++ and Windows SDK
I''m trying to use SetCursor() to change the cursor image while my program is running.
I load a cursor from a resource into an HCURSOR handle and pass it to SetCursor(). The new cursor image shows up indeed, but it flashes overtop of the old arrow cursor that I loaded when initializing my windows class. Here''s the relevant part of my code:
Any thoughts?
//Initialize the window class
HWND hwnd;
WNDCLASS wndclass;
wndclass.lpfnWndProc = WindowProc;
wndclass.style = CS_DBLCLKS|CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hinstance;
wndclass.hIcon = LoadIcon(hinstance,IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "MYWINCLASS";
//Register the window class
if(RegisterClass(&wndclass)==0) {
ErrorMsg("Error registering window class",hwnd);
return 0;
}
//Create the game window
hwnd = CreateWindow("MYWINCLASS","Orb Of Fish Window",WS_POPUP|WS_VISIBLE,0,0,640,480,NULL,NULL,hinstance,NULL);
//Show the cursor
ShowCursor(true);
////////////////
//
// 500 lines of irrevelent code later...
//
////////////////
//Load a new home-made cursor from a resource
HCURSOR cursor_new = LoadCursor(hinstance,MAKEINTRESOURCE(IDC_CURSOR1));
SetCursor(cursor_new);