Hello, is it possible to convert Mouse Cursor from Geometry I have a bit of UI on my screen, which I'd like to turn to a Mouse Cursor.
Thanks.
Hello, is it possible to convert Mouse Cursor from Geometry I have a bit of UI on my screen, which I'd like to turn to a Mouse Cursor.
Thanks.
Cursor from Geometry
spointer
Once you've rendered the visual out to a bitmap, the easiest way to create a cursor from it is to simply load the newly created bitmap from System.Drawing and call GetHicon on it. If you wrap the handle returned from that call inside a SafeHandle, then you can safely call System.Windows.Interop.CursorInteropHelper.Create(), no .cur files or P/Invoke's are required except maybe for a call to DestroyIcon().
It's ugly but it works great. I have a basic walk through here
Giorgi Moniava
I guess you could hide the mouse cursor and RenderTransform/Translate a DrawingBrush or Image in response to the MouseMove event...
Not what you'd wish for, but doable...
JimmyJen
The parent (and its parent and its parent and ...) also get the mousemouse and previewmousemouse events. (If that's what you mean)
Cheers
Mark.Sch
There is no direct support for custom cursors in WPF AFAIK, but you could render the geometry to a bitmap using RenderTargetBitmap and then use P/Invoke to manipulate the cursor using the Win32 API if you wanted.
HTH,
Drew
ultra03
That's a mess, to be honest with ya. :) Anyway - I don't use p/invoke in principle. I'm still struggling with D'n'D. Is there any way to make a control transparent for the events What I mean is - automatically re-translate event to the FrameworkElement -> Parent < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Alex Flash
There is no direct custom mouse cursor as far as I am aware.
I am suppressing the standard cursor by setting it to Cursors.None and then drawing a WPF graphic (geometry, shape or whatever) at the mousepoint.
Seems to work OK. Some issues with the MouseMove event as it goes over Adorner elements but I just raise an event in the Adorner and handle it in the canvas that the cursor is active in.
This gives me a WPF cursor which is quite effective as I can do a lot more eg show mouse position for a drawing program; colored cursors; show small icons of the drawing tool with current fill and stroke colors, etc.
John
s77007
No. (Well, if you really wanted to, you could as someone else mentioned dump the geometry to a bitmap, then convert the bitmap into an HCURSOR or .cur, but that's a fairmount of work...)