Looking for Assistance to create Custom Cursor

0
1

I’m building a vb.net web app using WiseJ 2.5.  I want to initiate a custom cursor on a button click.  Ideally, I’d like to use a bitmap I can build on the fly unique to the designated button.  If that’s not possible I’d use one of a series of custom .cur files as the cursor.  I’ve tried both.  The issue isn’t building the bitmap or the .cur file but changing the cursor.  I must assume this requires the use of a javascript widget, as none of the typical methods I’ve used for creating this inside a form application are working.  I’m not sure as, for what ever reason, the WiseJ API won’t load completely (hangs up) and I haven’t been able to do more research.  I looked through the WiseJ examples on GitHub and haven’t found anything obvious there yet either.

Is there a script or code snippet for changing the cursor from the system cursors to a custom one?

Thanks!

Gerry

 

 

  • You must to post comments
0
0

Hi Gerald,

thanks for getting back on this and providing a test case.

There is one minor bug in your code as you´re checking for RadioButton2 twice. If you change the last occurrence to RadioButton3 and also switch to this code, building a cursor from a bitmap works fine if you supply the image:

ElseIf RadioButton3.Checked = True Then
 'Use bitmap as icon
 Dim bmCur As New Bitmap(60, 60)

Dim g As Graphics = Graphics.FromImage(bmCur)
 g.FillRectangle(Brushes.Transparent, 0, 0, 60, 60)
 g.DrawEllipse(Pens.Red, 10, 10, 40, 40)
 g.DrawEllipse(Pens.Red, 0, 0, 60, 60)
 g.DrawEllipse(Pens.Red, 30, 30, 1, 1)
 g.DrawEllipse(Pens.Red, 25, 25, 10, 10)

Dim ptrCur As IntPtr = bmCur.GetHicon

Dim cur As Cursor

'cur = New Cursor(ptrCur)
 cur = New Cursor(bmCur)

I will check in more detail why providing the IntPtr from a Loaded cursor won´t work yet.

Best regards
Frank

 

  • You must to post comments
0
0

Hi Frank,

Sorry for the delay!  I uploaded a test case.  System cursors work fine.  I want to create custom cursors as I have on previous projects,

I appreciate your insight!

Gerry

Attachment
  • You must to post comments
0
0

Hi Gerald,

it should be as simple in Wisej.NET as in WinForms

this.button1.Cursor = Cursors.Hand;

Does it work for a standard cursor for you and only fail for custom cursors? In any case a repro case would help a lot to track down that issue.

Best regards
Frank

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.