[ACCEPTED]-Set Custom Cursor from Resource File-cursor
Guessing the resource name can be difficult. To 7 find out, run Ildasm.exe on your program. Double-click 6 "Manifest" and look for the .mresource.
Another 5 way to do it that avoids guessing: Project 4 + Properties, Resource tab. Click the arrow 3 on the "Add Resource" button, Add Existing 2 File and select your .cur file. Make your 1 code look like this:
Dim ms As New System.IO.MemoryStream(My.Resources.Cursor1)
Button1.Cursor = New Cursor(ms)
Thanks for the help! I assumed that if 7 I created the resource in the Visual Studio 6 IDE it would add it to my project. Silly 5 me!
I had to go to the Project tab to add 4 the Window.Cur file using Add Resource (thanks 3 nobugz!) and then use the code he mentioned:
Dim ms As New System.IO.MemoryStream(My.Resources.Window)
Button.Cursor = New Cursor(ms)
I 2 would vote up on the answer if I could but 1 I can't as I only have a value of 13 currently.
You are missing the namespace. You probably 3 want to use:
MyNamespace.MySubfolder.Window.cur
EDIT: Also, make sure your Build 2 Action for the item is "Embedded Resource", otherwise 1 it will not be include in your dll/exe.
Suppose you are assigning "Cursor1.cur" to 3 be the cursor for the control "Button1."
In 2 your Form.Load event you would do something 1 like -
Button1.Cursor = New Cursor(Me.GetType(), "Cursor1.cur")
you mustn't use 32bit color cursors.
0
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.