C # Changing cursor / cursor position?

Thus, the default cursor is the Arrow cursor, and the upper left part of the arrow (where the point is) is the part that clicks or interacts with other controls. How to change the index part to say arrow tail?

I have a custom cursor (bitmap), which is a 16x16 circle, and I want its center to be a pointer. I have another custom arrow cursor that points down-left and 16x16, and I want the bottom left corner of the cursor to be a pointer. I think there is a property in the cursor class for this, but I'm not sure what he called.

+6
source share
3 answers

This is actually indicated in CUR format.

The CUR file format is an almost identical image file format for unanimated cursors in Microsoft Windows. The only differences between the two file formats are the bytes used to identify them and the addition of an access point in the header of the CUR format; An access point defined as the pixel offset (at x, y coordinates) from the upper left corner of the cursor image, where the user actually points the mouse.

Programs that can edit CUR files usually allow you to specify a hot spot. More information can be found in this question .

+6
source

There is a rather thorough article on the topic: http://www.switchonthecode.com/tutorials/csharp-tutorial-how-to-use-custom-cursors

It covers cursor customization, creating a cursor through a custom structure and bitmap, and combining all of it into an application.

+2
source

What you want cannot be done through code. I wanted to do the same, but that is not possible. In fact, the cursor class has the HotSpot property, which is the point you want to change. However, this property is read-only. The only way to change this is to download the file (in the .cur file, I suggest you use Paint.net with the cursor and icon plugin (search over the network) to edit the cursor). Important: the cursor must be a file, not a resource or such things (must be a file in the file system) to load it. Remember this, I had a bad time testing in other ways.

The idea that I have in mind is: edit the cursor file only when you need to change the access point, however, for this you need to write an api that allows you to change the access point in the cursor file. I obviusly don't know how this file is built, so you should continue here.

Hope this was helpful

+1
source

Source: https://habr.com/ru/post/893389/


All Articles