Results 1 to 3 of 3

Thread: [RESOLVED] [Win32/C++] Change cursor to IDC_HAND on BS_OWNERDRAW button

  1. #1

    Thread Starter
    New Member imchillato's Avatar
    Join Date
    Apr 2026
    Posts
    3

    Resolved [RESOLVED] [Win32/C++] Change cursor to IDC_HAND on BS_OWNERDRAW button

    Hello guys , 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?
    Thank you for help! ~imchillato

  2. #2

  3. #3

    Thread Starter
    New Member imchillato's Avatar
    Join Date
    Apr 2026
    Posts
    3

    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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width