Vlasta
on September 10th 2008
0
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?
Anonymous
on September 11th 2008
0
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.
The Spud
on September 11th 2008
0
Sorry, Forgot to log on before posting previous message. Also seem to be having some kind of smiley problem with my brackets.
Vlasta
on September 11th 2008
0
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 });
The Spud
on September 13th 2008
0
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.