//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);
Windows SetCursor() problem
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?
i think you have to overwrite the cursor handle in the wndclass with the new cursor handle. as far as i can remember, you''d have to use "SetClassLong" for this. this should help but i don''t know wether it is a hack or if it''s ok to do this!
I think you have to call SetCursor on ever WM_MOUSEMOVE message that occurs in the windows procedure.
I personally would go with morebeer''s solution but if you want to use SetCursor() when the cursor enters the client area to change the cursor you will have to set the class cursor to NULL.
Qui fut tout, et qui ne fut rien
Invader''s Realm
quote:From MSDN, SetCursor()
If your application must set the cursor while it is in a window, make sure the class cursor for the specified window''s class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved.
Qui fut tout, et qui ne fut rien
Invader''s Realm
quote:Original post by Zoomby
I think you have to call SetCursor on ever WM_MOUSEMOVE message that occurs in the windows procedure.
on every WM_SETCURSOR message.
My Site
quote:
From MSDN, SetCursor()
If your application must set the cursor while it is in a window, make sure the class cursor for the specified window''s class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved.
Thanks a billion! The said restoration of the cursor every time the mouse is moved is EXACTLY my problem. Fixed.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement