问题
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
回答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.
回答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.
来源:https://stackoverflow.com/questions/11526351/change-hotspot-of-a-custom-cursor