Color cursor usage?

I want to be able to load a color cursor (16-color or 256-color) from a cursor resource for use in my application.

Can this be done, and if so, how?  I have tried LoadCursor(), LoadImage(), LoadIcon() etc. and then passed the handle to SetCursor().  However, I cannot get a color cursor.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you want the cursor to be "application wide" or for a specific control or window ?

What OS are you using and what language are you trying to compile in ?? (ie BC++ or VC++ etc)

Perhaps a code fragment of how you are doing it might be useful as well.

OK - I think I have your answer (I've tried the following and it works for me fine).

If you have VC++ 5 or VC++ 6.0 the following applies :

Create a new icon resource - in the middle of the bottom part of the toolbar above the icon image you'll see a window "Device" and a drop down listbox next to it. Click on the window (button) on the right of the dropdown and create a "new cursor Image" - click on "custom" and create the new device image after selecting your requirements.

Once having done that - go back to the dropdown and select "monochrome". Then go to the "Image" menu and select "Delete Device Image". (Make sure the "monochrome" image is selected).

Use something similar to the following code snippet, to create the cursor image for use :

HICON hIcon_Old;

  hIcon = LoadImage(      hInstance,

                    hIcon_Old = SetCursor(hIcon);

// Insert your code here

Windows by default finds the first cursor image in an image directory (an image with more than one image in it).

By deleting the monochrome image and replacing it with your new colour image you force windows to use it.

There are other ways - but this one is the most simple and probably the most effective without interogating the cursor structure.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dmetzlerAuthor Commented:

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.