Custom Colour Cursor

P

Paul Cheetham

Hi,

I have several Colour custom cursors embedded in my application resource.
In order to load and use them I use the following function:

public static Cursor LoadCursor (string CursorName)
{
Cursor myCursor;
Stream cursorStream;
Assembly thisAssembly;
String Name;

thisAssembly = Assembly.GetEntryAssembly();
Name = "ProLogic.Cursors." + CursorName + ".CUR";
cursorStream = thisAssembly.GetManifestResourceStream(Name);
myCursor = new Cursor(cursorStream);

cursorStream.Close();

return (myCursor);
}


This loads the cursor, but only in Mono.
Does anyone know how I can get the cursor to display in colour as it was
designed?

Thankyou.

Paul.
 
M

Michael Phillips, Jr.

Per the documentation, the Cursor class does not support
..ani cursors or color cursors. It only supports black and white.

You need to use interop P-Invoke LoadImage exported from user32.dll
to load the cursor from your resource.
 
P

Paul Cheetham

Michael said:
Per the documentation, the Cursor class does not support
.ani cursors or color cursors. It only supports black and white.

You need to use interop P-Invoke LoadImage exported from user32.dll
to load the cursor from your resource.

Hmmm.... Seems like a step backwards.
Presumably I can use the Win32 LoadCursor function which gives me an
HCursor.

Is there then a way to assign this to the cursor class?


Thanks.


Paul
 
M

Michael Phillips, Jr.

The Cursor class has a constructor that can be used
with the HCURSOR (IntPtr) handle.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top