For some reason, when i use SetClassLong(%WND%, GCL_HCURSOR, LoadCursor(0, IDC_HAND)), all the buttons including the MessageBox button's will get tht HAND cursor ? any ideas why ?
Posted on 2006-03-13 08:04:10 by XCHG
Because it changes the cursor setting for all windows of a specified class.
Posted on 2006-03-13 09:37:10 by arafel
If you need to set different cursor for some single control there is a way to do it with subclassing and mouse tracking messages. Perhaps there is better way, but this works for me fine.

subclass_of_a_static_control PROC hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD

?  ?  ?  ?  mov?  ?  ? mousetrac.dwFlags, TME_HOVER
?  ?  ?  ?  mov?  ?  ? eax, hWin
?  ?  ?  ?  mov?  ?  ? mousetrac.hwndTrack, eax
?  ?  ?  ?  invoke?  TrackMouseEvent, ADDR mousetrac

?  ?  ?  ?  .if uMsg == WM_MOUSEHOVER

?  ?  ?  ?  invoke?  SetCursor, cursor_hand ; when a mouse is over the control
; cursor will change to hand
?  ?  ?  ?  mov?  ?  ? mousetrac.dwFlags, TME_LEAVE
?  ?  ?  ?  mov?  ?  ? eax, hWin
?  ?  ?  ?  mov?  ?  ? mousetrac.hwndTrack, eax
?  ?  ?  ?  invoke?  TrackMouseEvent, ADDR mousetrac

?  ?  ?  ?  invoke?  InvalidateRect, hWin, 0, FALSE

?  ?  ?  ?  .elseif uMsg == WM_MOUSELEAVE ; when mouse leaves the control, cursor will
; switch back to the original class cursor.
?  ?  ?  ?  mov?  ?  ? mousetrac.dwFlags, TME_HOVER
?  ?  ?  ?  mov?  ?  ? eax, hWin
?  ?  ?  ?  mov?  ?  ? mousetrac.hwndTrack, eax
?  ?  ?  ?  invoke?  TrackMouseEvent, ADDR mousetrac

?  ?  ?  ?  invoke?  InvalidateRect, hWin, 0, FALSE

?  ?  ?  ?  .elseif uMsg == WM_SETCURSOR

?  ?  ?  ?  mov?  ?  ? eax, TRUE
?  ?  ?  ?  ret

?  ?  ?  ?  .endif

?  ?  ?  ?  invoke?  CallWindowProc, original_handle, hWin, uMsg, wParam, lParam
?  ?  ?  ?  ret
subclass_of_a_static_control ENDP
Posted on 2006-03-13 09:53:08 by arafel
oh i see, thanks a lot, i appreciate it.
Posted on 2006-03-14 00:29:50 by XCHG