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.

Thanks,

Don
dmetzlerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DarrinEConnect With a Mentor Commented:
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 :

HANDLE hIcon;
HICON hIcon_Old;

  hIcon = LoadImage(      hInstance,
                                                      MAKEINTRESOURCE(IDC_CURSOR1),
                                                      IMAGE_CURSOR,
                                                      GetSystemMetrics(SM_CXSMICON),
                                                      GetSystemMetrics(SM_CYSMICON),
                                                      LR_VGACOLOR);


                    hIcon_Old = SetCursor(hIcon);

// Insert your code here
                    SetCursor(hIcon_Old);

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.

DarrinE
0
 
DarrinECommented:
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.

DarrinE
0
 
dmetzlerAuthor Commented:
Thanks!

Don
0
All Courses

From novice to tech pro — start learning today.