Is it possible to use Real World cursors in Visual Basic applications?
I get the following error message:
"Image format is not valid. The image file may be corrupted. Parameter name: stream"
Any help would be appreciated, Thanks
I did not try that myself, but it should be possible. What kind of cursor (static, animated, color depth) did you try to use and how?
I just made a simple black and white static cursor (that I named "NewArrow") as a trial, and used the following code:
Dim Cur As New Cursor("C:\Documents and Settings\Administrator\My Documents\My Pictures\NewArrow.cur")
Windows.Forms.Cursor.Current = Cur
I also tried using cursors from the RealWorld Cursor Editor library without success. However, when I tried a custom made cursor (that was included with a program that I had downloaded) using the same VB code it worked.
Sorry, Forgot to log on before posting previous message. Also seem to be having some kind of smiley problem with my brackets.
Did a couple of test with C# and yes, you are right. .NET cannot load any cursor except black and white (you need to select monochromatic format when creating the cursor in the editor) with its native methods. I thought the later versions of the .net framework were better, but it still sucks after 5 years of development...
Here is a workaround in C#, which should be easy to transform to VB code.
[System.Runtime.InteropServices.DllImport("user32.dll" )]
static extern IntPtr LoadCursorFromFile(string fileName);
IntPtr colorCursorHandle = LoadCursorFromFile("your-cursor.cur" );
Cursor.GetType().InvokeMember("handle", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetField, null, this.Cursor, new object[] { colorCursorHandle });
Changed my cursor to monochromatic and it works fine. Haven't been able to figure out the workaround in VB yet, but I'll get there eventually.
Thanks for your help, much appreciated.
Find out how Vista icons differ from XP icons.
See how RealWorld Icon Editor handles Vista icons.