Cursor Problems--Need help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bluemaster4
    New Member
    • Apr 2007
    • 3

    Cursor Problems--Need help

    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(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

    Dim newCursor As New Cursor(My.Resou rces.ResourceMa nager.GetStream ("C:\My Documents\Forum s\Main page\images\Cur sors\Main.cur") )

    Me.Cursor = newCursor
    End Sub


    Can somebody pleas tell me whats wrong with my code? Thanks for any help!!
  • Bluemaster4
    New Member
    • Apr 2007
    • 3

    #2
    Anybody???

    Comment

    • Aleksandar Djurdjevic
      New Member
      • Apr 2007
      • 11

      #3
      Try the following link:

      http://forums.microsof t.com/MSDN/ShowPost.aspx?P ostID=1494279&S iteID=1

      but there is example in C# code,so try to find conveter...

      Comment

      • Aleksandar Djurdjevic
        New Member
        • Apr 2007
        • 11

        #4
        Hello,i solved this...try the following code:


        Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load


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

        Me.Cursor = newCursor



        End Sub

        Comment

        • SammyB
          Recognized Expert Contributor
          • Mar 2007
          • 807

          #5
          Originally posted by Aleksandar Djurdjevic
          Hello,i solved this...try the following code:


          Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) 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.

          Comment

          • Aleksandar Djurdjevic
            New Member
            • Apr 2007
            • 11

            #6
            @SammyB

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

            (My.Resources.R esourceManager. GetStream)

            and it worked very well...

            Comment

            • Bluemaster4
              New Member
              • Apr 2007
              • 3

              #7
              Thanks, I dident know msdn had that stuff on it... then again i ushally get lost on that site.

              Comment

              • SammyB
                Recognized Expert Contributor
                • Mar 2007
                • 807

                #8
                Originally posted by Bluemaster4
                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.

                Comment

                • SammyB
                  Recognized Expert Contributor
                  • Mar 2007
                  • 807

                  #9
                  Originally posted by Bluemaster4
                  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(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

                  Dim newCursor As New Cursor(My.Resou rces.ResourceMa nager.GetStream ("C:\My Documents\Forum s\Main page\images\Cur sors\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:
                  Code:
                  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

                  Comment

                  Working...