question

JimWebb-7615 avatar image
0 Votes"
JimWebb-7615 asked Castorix31 answered

Detect change in mouse cursor

Is it possible to detect the cursor change when the mouse moves over a control - for example when the cursor moves to the side of a window it changes from default to the Cursors.SizeWE (left-right arrow) cursor. I have tried using the CursorChanged event but it doesn't fire when the cursor changes. Is there something I am not setting in the event handler or do I need to use another event handler? The current code I am using is:

  Private Sub myForm_CursorChanged(sender As Object,
     e As EventArgs) _
     Handles Me.CursorChanged
    
  MyCur As Windows.Forms.Cursor = Me.Cursor
    
  End Sub

HotIndigo

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered

A way is with SetWinEventHook
with
EVENT_OBJECT_NAMECHANGE
and test if idObject = OBJID_CURSOR
in the event hook function

(tested on Windows 10 1909)




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.