0

I'm using a custom cursor that I loaded in this way:

Bitmap bit = new Bitmap(path);
cur = new Cursor(bit.GetHicon());
Cursor.current = cur;

my bitmap is a 44x58 png and the mouse hot spot is not exactly where I want to be. I looked for a property to change the mouse hot spot but the only one I found is readable-only (cur.Hotspot). What I need to do for change its coordinates?

Thanks

animuson
  • 53,861
  • 28
  • 137
  • 147
Frank Lioty
  • 949
  • 3
  • 10
  • 17
  • Does that help? http://stackoverflow.com/questions/550918/change-cursor-hotspot-in-winforms-net – Otiel Jul 17 '12 at 15:59
  • 1
    Duplicate of http://stackoverflow.com/questions/550918/change-cursor-hotspot-in-winforms-net as pointed out by @Otiel – Ani Jul 17 '12 at 16:00
  • @ananthonline all I need is to change also offline my hot spot. Also ok with a software or something similar. – Frank Lioty Jul 17 '12 at 17:50

2 Answers2

1

In Visual Studio, open the cursor file or resource in the image editor and select the Hotspot Tool from the toolbar. Then click on the new hotspot and save the file. AFAIK there is no way to set the hotspot via the .NET API, but there are options via the WIN32 API, as demonstrated in the links in the others' comments.

  • all I need is to change also offline my hot spot. Also ok with a software or something similar. – Frank Lioty Jul 17 '12 at 17:50
  • If you see the set-hotspot button disabled, than you have to change the first bytes of the file from 00 00 01 00 to 00 00 02 00 (credit: [link](https://developercommunity.visualstudio.com/t/hot-spot-tool-in-the-image-editor-is-disabled/1695646)) – Peter Ferencz May 02 '23 at 21:11
-2

At the end I simply decide to hide the mouse cursor and draw a bitmap at the hotspot coordinates. Too much complicated the solution suggested.

cursor = new Bitmap(path);

in MouseMove event:

ex = e.X - offx //the x offset of the hotspot
ex = e.X - offy //the y offset of the hotspot

then paint as last drawing element the bitmap at the (ex,ey) coordinates.

Frank Lioty
  • 949
  • 3
  • 10
  • 17