Reputation: 117
I am trying to change the cursor image in my c++ file. For some reason it isn't working when I execute the program. I used the LoadCursorFromFile and SetCursor methods but something is clearly wrong. I have included the problematic portion of the code. Any help is much appreciated in advance! Thanks for your time.
problematic code
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HCURSOR cursor = LoadCursorFromFile("mouse.cur");
HCURSOR SetCursor(cursor);
MSG msg;
int counter = 1;
int posx = 0;
int posy = 0;
int seriesinc = 0;
int arrays;
int xPos, yPos;
Upvotes: 0
Views: 497
Reputation: 308158
Your window will respond to WM_SETCURSOR
messages by setting the cursor to the default arrow. You may have seen that the cursor changed for just an instant after calling SetCursor
before changing back - that was the time between the call and the next WM_SETCURSOR
message.
You should create a handler for the WM_SETCURSOR
message and call SetCursor
there, then return TRUE
.
Upvotes: 1
Reputation: 283634
This is a variable declaration, not a function call:
HCURSOR SetCursor(cursor);
What you wanted was either
::SetCursor(cursor); // discard return value
or
HCURSOR prevCursor = ::SetCursor(cursor);
Upvotes: 4