Cursor with colors

  • Thread starter Thread starter Markus Wildgruber
  • Start date Start date
M

Markus Wildgruber

Hi!

I made a cursor with a 16 color palette and saved it to a .cur-file. When I
load that file into a cursor class and set the cursor of a form to my
cursor, the cursor is displayed in monochrome mode (although there is no
image type with a monochrome palette).
Does anyone know how to tell windows forms to use the color palette?

TIA,

Markus
 
Hi Markus,

According to the document of Cursor class ,
"The Cursor class does not support animated cursors (.ani files) or cursors
with colors other than black and white."

This is a known issue in .NET,
I think you may try loading the cursor by PInvoke the API LoadCursor and
handling the WM_SETCURSOR by overriding the WndProc for your control.
Here is an sample snippet for loading the cursor:
<code>
[DllImport("user32.dll", EntryPoint="LoadCursorFromFile")]
public static extern int LoadCursorFromFile(String FileName);

private void button1_Click(object sender, System.EventArgs e)
{
Cursor cursor=new Cursor(new
IntPtr(LoadCursorFromFile(@"C:\WINDOWS\Cursors\3dgmove.cur")));
this.Cursor=cursor;
}
</code>
Does this work around solve your problem?
Please be free to reply to this thread if you have any problem on this
issue.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending.
 
Hi!

Thanks for your answer. I tried to load the cursor using PInvoke and the
LoadCursorFromFile function and passed the resulting handle to the
constructor of the Cursor class. That way, the color palette was used and
the cursor was displayed as expected.

We are working on a large project and spent a lot of time on fundamentals
that help us accelerate our development process. As you can certainly
understand, loading resources using PInvoke is not a good match with the way
we handle resources right now. From that point of view we simply cannot use
PInvoke or an unmanaged resource-dll.

As .NET is state of the art technology it is a pity that the framework's
cursor class does not support that feature. We can just hope that this will
be implemented in future versions or a service pack. Does Microsoft have
plans to implement that?

Thanks for your help,

Markus
 
Hi Markus,

Thanks for your reply,

I fully understand your feeling, however I'm unable to tell you if the
feature will be added to our future products, it's depended on the plans of
product groups and the
features are subject to change. You may read the release note or post the
questions in our newsgroup when a new version or sevice pack is released.

Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending.
 
Back
Top