Private
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadDim Cur As Cursor = New Cursor("c:\windows\cursors\pen_rm.cur")Me.Cursor = CurEnd SubThanks for the help! I will definantly try this code. Although I am Guessing I should change the
("c:\windows\cursors\pen_rm.cur") to
(my.resources.MyCursor.cur) because it is embedded. ![]()
I tried it and this error message came up. It is probely something basic, but is there possibly anything left out in the line:
Dim Cur As Cursor = New Cursor("c:\windows\cursors\pen_rm.cur")
Thanks for trying!
Error 1 Overload resolution failed because no accessible 'New' can be called with these arguments:
'Public Sub New(stream As System.IO.Stream)': Value of type '1-dimensional array of Byte' cannot be converted to 'System.IO.Stream'.
'Public Sub New(fileName As String)': Value of type '1-dimensional array of Byte' cannot be converted to 'String'.
'Public Sub New(handle As System.IntPtr)': Value of type '1-dimensional array of Byte' cannot be converted to 'System.IntPtr'. C:\Documents and Settings\Brian\My Documents\Visual Studio 2005\Projects\Target Practice\Target Practice\Form1.vb 575 29 Target Practice
I'm sorry. I posted code to load a cursor from a file, not an embedded resource.
The only 'hack' I can figure out to use, to load the cursor as an embedded file, is to create it as an icon. (and then do some jumping through hoops!)
I think currently cursors can only be black and white and transparent color and 32x32.
Anyway, to load an icon (from a file, but it will become an embedded cursor,) is as follows:
(Experts. Please help on this and tell him the right way to do this!)
Public
Class Form1' add an empty 'form2' to your project to reset form1's icon from.' In the form1 designer, make the cursor 'ico' file,' the icon for form1. Then ...Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadDim curr As New Cursor(Me.Icon.Handle)Me.Cursor = currMe.Icon = My.Forms.Form2.IconEnd SubEnd
ClassTry:
Dim m As New System.IO.MemoryStream(My.Resources.MyWackyCursor)
Me.Cursor = New Cursor(m)
Unfortunately, cursors like this are only B&W (Tall dude mentioned that). You can create color ones (if you want) using the LoadCursorFromFile Win32 API, but that requires an actual file.
Thanks for the code SJWhiteley, it worked!
Dim
m As New System.IO.MemoryStream(My.Resources.crosshaircur)Me.Cursor = New Cursor(m)
This is the exact code I used.
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Stephen,
Thanks for showing us the correct way to do this.
BTW, when I used my 'hack' way, the cursor/pointer did not persist through
the lifetime of the application.
Can you explain why? Just curious.