[Closed] Dotnet – Dotnet Shape to Mouse Cursor
I want to make a custom shape and then have that as a cursor using dotnet.
How can I convert a dotnet drawing object to a cursor?
cursors = dotNetClass "System.Windows.Forms.Cursors"
--hand_move = dotNetObject "System.Windows.Forms.Cursor" "C:\WINDOWS\Cursors\cross_rm.cur"
hand_move = dotNetObject "System.Drawing.Rectangle" 0 50 0 50
cursors.Hand.Current = hand_move
(
local bmp = dotNetObject "System.Drawing.Bitmap" 50 50
local gfx = (dotnetClass "system.drawing.graphics").fromImage bmp
local rect = dotNetObject "System.Drawing.Rectangle" 0 0 50 50
gfx.FillEllipse (dotNetClass "System.Drawing.Brushes").red rect
gfx.dispose()
local hCursor = dotNetObject "System.IntPtr" (bmp.getHIcon())
(dotnetClass "Cursor").current = dotNetObject "Cursor" hCursor
)
Of course, this will only last until you move the mouse as max will send a WM_SETCURSOR message on each mouse move.
If it’s for a specific form, use the form.Cursor property instead.
If you need to replace the mouse cursor, you will need to take over the 3dsmax wndproc and override the WM_SETCURSOR messages.
Thanks Lo.
As it’s in the MouseDown event handler for a dotnet button it gets called repeatedly which is what I need.
In that case you should use the Cursor property of the button or form instead of B.current[/B]
Also be sure to dispose of your bitmaps properly.
I would love to know what you are doing with this Dave. Sounds interesting.