12-21-2020 12:00 PM
Does anyone know how to retrieve the current mouse cursor position on an image displayed in an image control with subpixel resolution?
I know you can retrieve the current cursor position with the "Last mouse position" property. However, this only gives you pixel accuracy. Is there a way to obtain this location more precisely?
Greetings, Manfred
Solved! Go to Solution.
12-21-2020 12:08 PM - edited 12-21-2020 12:12 PM
I don't know if that's possible. Out of curiousity, may I enquire as to why you need this information? Maybe you can get it in an indirect fashion by seeing how they do ClearType?
12-21-2020 12:13 PM
I'm writting an application that displays a crosshair at the current position of the mouse cursor. If the user zooms in quite a bit (for editing the edges of a graphical object) the displayed crosshair is not matching the cursor position which looks odd.
12-21-2020 12:19 PM
@mprantl wrote:
I'm writting an application that displays a crosshair at the current position of the mouse cursor. If the user zooms in quite a bit (for editing the edges of a graphical object) the displayed crosshair is not matching the cursor position which looks odd.
Is it possible to work around this issue by only letting the user zoom in factors that will result in integer values for x and y?
12-21-2020 12:25 PM
This will not solve the issue. The mouse cursor moves in screen pixels. Once the pixels of the image become larger than one screen pixel the coordinates (and hence my cross hair) will be off from the actual position of the mouse cursor.
12-21-2020 02:01 PM
The way I see this solved in other applications that zoom like this is to have the cross-hair "follow" the cursor - that is, you'll have to calculate the "sub-pixel" size in real pixels, then have the cross-hair "snap" to that location. Every time the cursor crosses a "sub-pixel" boundary, it "snaps" to the new location.
12-21-2020 02:05 PM
If I understand you correctly then this is precisely what "Last Mouse Position" is doing.
Probably, there is no other solution so I will go with this. Thank you for your answers.