By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

Cursor Problems--Need help

P: 3
Hi, I am new to this forum and i have a problem with part of my application. I did not like the cursors that you had to pick from so i made my own and found this script so that i could use them. Well the script does not work and here is the error i get, "Object reference not set to an instance of an object.". I dont get what im doing wrong but here is the code im using,

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim newCursor As New Cursor(My.Resources.ResourceManager.GetStream("C:\ My Documents\Forums\Main page\images\Cursors\Main.cur"))

Me.Cursor = newCursor
End Sub


Can somebody pleas tell me whats wrong with my code? Thanks for any help!!
Apr 22 '07 #1
Share this Question
Share on Google+
8 Replies


P: 3
Anybody???
Apr 22 '07 #2

P: 11
Try the following link:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1494279&SiteID=1

but there is example in C# code,so try to find conveter...
Apr 22 '07 #3

P: 11
Hello,i solved this...try the following code:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Dim newCursor As New Cursor("C:\Main.cur")

Me.Cursor = newCursor



End Sub
Apr 22 '07 #4

SammyB
Expert 100+
P: 807
Hello,i solved this...try the following code:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Dim newCursor As New Cursor("C:\Main.cur")

Me.Cursor = newCursor



End Sub
The reference for that is http://msdn2.microsoft.com/en-us/lib...38(VS.71).aspx. Ithought that I posted it last night, but must have been in my dreams! Also, the way that you tried to do it also works, but I cannot remember how. If I remember, I'll post a tutorial.
Apr 23 '07 #5

P: 11
@SammyB

I didn't knew there is example on that site..from Bluemaster posted code i removed this piece:

(My.Resources.ResourceManager.GetStream)

and it worked very well...
Apr 23 '07 #6

P: 3
Thanks, I dident know msdn had that stuff on it... then again i ushally get lost on that site.
Apr 24 '07 #7

SammyB
Expert 100+
P: 807
Thanks, I dident know msdn had that stuff on it... then again i ushally get lost on that site.
It's very difficult, but when you get help in VB.Net, it gives you the URL, so I just used that. One of these days I'll remember how to do it with GetStream, until then, glad this helped.
Apr 24 '07 #8

SammyB
Expert 100+
P: 807
Hi, I am new to this forum and i have a problem with part of my application. I did not like the cursors that you had to pick from so i made my own and found this script so that i could use them. Well the script does not work and here is the error i get, "Object reference not set to an instance of an object.". I dont get what im doing wrong but here is the code im using,

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim newCursor As New Cursor(My.Resources.ResourceManager.GetStream("C:\ My Documents\Forums\Main page\images\Cursors\Main.cur"))

Me.Cursor = newCursor
End Sub

Can somebody pleas tell me whats wrong with my code? Thanks for any help!!
I figured out the Stream thing. It's simple, but you need to follow these instructions exactly:
  1. Start a new windows VB.NET app, call it CursorDemo
  2. Use the Project, Add Existing Item menu to add a Cursor file to your project. My filename was arror_r.cur, You will have to change the files of type filter to all files to see cur files.
  3. In the Solution Explorer, click on the cursor file; and in the Properties window, change the Build Action from Content to Embedded Resource.
  4. Double click on the form to create the load event and add the following line:
Expand|Select|Wrap|Line Numbers
  1. Me.Cursor = New Cursor (Me.GetType().Assembly.GetManifestResourceStream("CursorDemo.arrow_r.cur"))
Notice that my project name & cursor filename are inside the quotes.
This way you do not need to distribute the cursor file: it is embedded in your exe/pdb. Fun & Games! --Sam
Apr 24 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.