C # - Cursors.Hand.Handle does not identify the "Hand"

1

I made a program to identify whether the mouse cursor is Hand or not. I'm using an event that identifies the global cursor, so even out of Form it is able to identify. The problem is that in function:

private static bool Cursor()
    {
        var h = Cursors.Hand.Handle;

        CURSORINFO pci;
        pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
        GetCursorInfo(out pci);

        return pci.hCursor == h;
    }

When I test it on a button by placing the mouse over some link or something else that makes the cursor Hand , it does not identify! But if I change and put Cursors.Default.Handle it always identifies whether the cursor is Default or not.

What am I doing wrong? How to identify whether the cursor is Hand or not?

    
asked by anonymous 06.12.2015 / 23:42

1 answer

0

I think you're picking up the wrong cursor,

Try this out

private static bool Cursor()
    {
        var h = Cursor.Current;

        CURSORINFO pci;
        pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
        GetCursorInfo(out pci);

        return pci.hCursor == h;
    }
    
07.12.2015 / 18:20