Windows Develop Bookmark and Share   
 index > Windows Forms General > Custom cursor image impossible to use in .NET code, but works in windows control panel.
 

Custom cursor image impossible to use in .NET code, but works in windows control panel.

I havea problem with a .cur file from CursorWorkshop.

I am having a cursor with 32x32 RGB/A, 32x32 256, 32x32 16 and 32x32 mono image formats.

When I do the

this.Cursor = new Cursor(GetType(), "Arrow1.cur");

call, it fails with an ArgumentException, Image format is not valid.

If I remove the 32x32 RGB/A image, there is no exception, but my cursor is completely black!

WinXP and later should support 32x32 RGB/A, andmy windows control panel will let me use the cursor without any problems!

Does anyone have any ideas of how to use the 32x32 RGB/A, or the 32x32 256 cursor image without it going blackat least,or working with cursor files in general in .NET?

I suspect this is a problemt with .NET and support of cursors, but I have no idea. If anyone have any experience with using custom cursors, please feel free to share your experiences.

Cheers,
Chris
HalfAsleep  Thursday, February 12, 2009 12:55 PM
The Cursor class doesn't yet support loading animated and hi-color cursors. Check this thread for a workaround.
Hans Passant.
  • Marked As Answer byHalfAsleep Friday, February 13, 2009 1:33 PM
  •  
nobugz  Friday, February 13, 2009 11:26 AM

Hi HalfAsleep,

I don't know how you create the 32X32 RGB/A image. Base on my test, I can set the cursor's image directly from a *.cur file.

this.Cursor=newCursor(@"D:\help_l.cur");


for example.

Maybe you need to send me the project and let me test the problem.
My email is v-kiqian@microsoft.com. Please send with the title "MSDN forum - Custom cursor image...".
So I can test it to know the issue better.

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Friday, February 13, 2009 8:50 AM
The Cursor class doesn't yet support loading animated and hi-color cursors. Check this thread for a workaround.
Hans Passant.
  • Marked As Answer byHalfAsleep Friday, February 13, 2009 1:33 PM
  •  
nobugz  Friday, February 13, 2009 11:26 AM
Thanx a bunch, that did the trick! :D

Cheers,
Chris
HalfAsleep  Friday, February 13, 2009 1:33 PM

You can use google to search for other answers

Custom Search

More Threads

• File picker/file browser control
• How to get a separator line?
• Displaying selected items in an unfocused ListView
• Resizable Custom Control
• While a process is active....
• What toggles the IME?
• combo box requirement
• Vista
• GridView to PDF document
• How to Implement Custom ComboBox?