I have seen multiple programs where you can choose a fancier mouse cursor to use instead of the plain white one. For instance, the cursor with a flame around it. I am in need of some code to change the mouse cursor to a specific Icon file on my computer. I would appreciate any code that you know works for sure.
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
I've tried many things, including what was in that thread. I always get this error:
"Image format is not valid. The image file may be corrupted.
Parameter name: stream"
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
"Object reference not set to an instance of an object."
Directed at the line: "curPCPI = New Cursor(cursorfile)"
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
"Image format is not valid. The image file may be corrupted.
Parameter name: stream"
Although, there is nothing wrong with my image.
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
"Image format is not valid. The image file may be corrupted.
Parameter name: stream"
Although, there is nothing wrong with my image.
that error can acure when the the file can't be read. Are you sure that the iamge file is .cur (cursor) file? and it exists in the resurs file with the same name?
Rating is a way of saying thank you. Don't forget to rate always!
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
I just tried adding a cursor file to the Resources tab and then accessing it via My.Resources. It produced that same error. That's doesn't really help you fix the issue but as far as I can see that should have worked so it at least confirms that you are not insane... or at least no more than me.
I am not sure why it happens but I am sure there is some thing wrong with the cursor file. Not if the image was created with the jpg format and later the extension got changed to .cur it does not change the format of the image. It is still have jpg format. Try to use it with another cursor file to test the code. You can find cursor file in the “C:\WINDOWS\Cursors” directory.
Rating is a way of saying thank you. Don't forget to rate always!
I tried it with an alternate Windows cursor, and I did not get any error, BUT, the cursor still didn't change, it stayed the same Default cursor.
EDIT:
Nevermind, I got the C:\Windows\Cursor to work, so the problem must be my image file. It was an Icon file, saved from an Icon editor, and I changed it to a .cur file, is that the problem?
Last edited by StreaksAthlete; Dec 10th, 2006 at 07:54 PM.
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
Error 1 Overload resolution failed because no accessible 'New' can be called with these arguments:
'Public Sub New(buffer() As Byte)': Value of type 'System.Drawing.Bitmap' cannot be converted to '1-dimensional array of Byte'.
'Public Sub New(capacity As Integer)': Value of type 'System.Drawing.Bitmap' cannot be converted to 'Integer'.
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
I created a resource from a standard Windows cursor file. I then tried loading that cursor from the disc file via a FileStream, which worked, and from the resource via a MemoryStream, which didn't. Can anyone see any obvious issues with this:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using fs As New IO.FileStream("C:\WINDOWS\Cursors\arrow_i.cur", IO.FileMode.Open)
Me.Cursor = New Cursor(fs)
End Using
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
The problem is that my file is not a valid .cur file. I renamed an Icon (.ico) to .cur which is most likely the problem. But, how do I make it a valid Cursor file?
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
The problem is that my file is not a valid .cur file. I renamed an Icon (.ico) to .cur which is most likely the problem. But, how do I make it a valid Cursor file?
If you renamed myfile.mdb to myfile.doc would you expect Microsoft Word to open it successfully? The extension doesn't change the contents of a file, only how Windows tries to handle it. An ICO file with a CUR extension is still an icon file. Visual Studio allows you to create cursor and icon objects. You'll need to open the icon, copy its graphical content and paste that into a new cursor. You then save the cursor as a resource and you can access it. I would suggest using the My.Resources method I showed previously.
The sarcasm isn't needed. I am thankfull for everybody's help! You guys should get paid for everyword.
Now, is there a way to make this custom cursor a System-Wide change?
Last edited by StreaksAthlete; Dec 10th, 2006 at 08:37 PM.
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar. If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option. We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
It wasn't sarcasm. It was an example to illustrate why what you were trying to do couldn't possibly work. Is that a guilty conscience I smell?
You can change the Windows.Forms.Cursor.Current property but every object will simply use its own cursor as soon as you move the mouse. If you want to affect the system-wide cursor settings then you'd have to edit those Windows settings. I would guess that those settings are stored in the registry. You can find them relatively easily by checking what the location of your current cursor is in the Mouse properties and then searching the registry for that value.
Last edited by jmcilhinney; Dec 10th, 2006 at 09:11 PM.
Ah so this is how to access randomly to the data! It seems the other stream objects dose not have that method. Good info! Sorry I can’t give any rep it doesn’t let me, but I like to. This is a good info thanks.
Rating is a way of saying thank you. Don't forget to rate always!
Ah so this is how to access randomly to the data! It seems the other stream objects dose not have that method. Good info! Sorry I can’t give any rep it doesn’t let me, but I like to. This is a good info thanks.
Some stream types can seek while others can't. Every stream has a CanSeek property to indicate whether it can or not. Those that can are usually those that are sitting on your own machine. Those that can't are usually those coming from elsewhere, like a NetworkStream. It doesn't make sense to randomly access a stream that you haven't received all of from a remote source.
Note that classes like a StreamReader are NOT streams and thus have no CanSeek property. A StreamReader is an object that reads text from a stream. Its BaseStream property is a reference to a stream. That stream has a CanSeek property. Note that a StreamReader can read any type of stream, including FileStream, MemoryStream, NetworkStream, etc. Whether you can reread the contents of a StreamReader depends on the type of its BaseStream, e.g.