Monday, July 21, 2008

.NET: Load Custom 32-bits Colored Cursor

By default, the ResourceStream only support up to 24-bits cursors, which means only black-and-white cursor can be loaded/imported.

To load colored cursor:
Call LoadCursorFromFile() from user32.dll.
If you want to load the cursor from the embedded resources, you can read the cursor into Byte[] and write it out to a temporary location, and then call LoadCursorFromFile().

LoadCursorFromFileW() - Unicode
LoadCursorFormFileA() - ANSI

Try using a colored Cursor. - MSDN Forums

An alternative way:
Loading the cursor from a bitmap. However, this is not recommended since we'll need to store the HotSpot in a separate location. The default HotSpot is the center of the image.

A Custom Cursor C# Friends

No comments: