[RESOLVED] [Win32/C++] Change cursor to IDC_HAND on BS_OWNERDRAW button
Hello guys :wave:, I'm having a little problem, as I created a button on GDI+ with:
Code:
HWND hBtnINFO = CreateWindowExW(0, L"BUTTON", L"asdasd", WS_VISIBLE | WS_CHILD | BS_OWNERDRAW, 350, 250, 16, 16, hwnd, (HMENU)BTN_INFO, NULL, NULL);
and I'm using BS_OWNERDRAW to draw myself a custom button with png circles, where if I click on it the cerchio1.png changes to a cerchio2.png, but my goal was that if the cursor passes over the button the cursor becomes the Cursor Hand symbol but I just can't do it... I tried to put it in the WM_COMMAND:
Code:
case WM_COMMAND: {
switch(wParam) {
case BTN_INFO:
SetCursor(LoadCursor(NULL, IDC_HAND));
MessageBox(NULL, "messaggeTest", "message", MB_OK);
}
}
break;
But it doesn't work as expected (it only triggers after the click, and even then, the cursor doesn't stay as a hand). What is the correct way to handle the hover cursor for an owner-drawn button? :confused:
Thank you for help! ~imchillato
Re: [Win32/C++] Change cursor to IDC_HAND on BS_OWNERDRAW button
You need to handle WM_SETCURSOR when wParam is hBtnINFO call SetCursor and return true.
Re: [Win32/C++] Change cursor to IDC_HAND on BS_OWNERDRAW button
Thank you so much!!!! I followed your advice and it works perfectly! I also added a call to DefWindowProc to reset the cursor when it hovers over the button to avoid flickering. God bless you!