We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

color mouse cursor

minnirok
minnirok asked
on
Medium Priority
616 Views
Last Modified: 2013-11-20
Hi,

Can someone explain how to set the mouse cursor from a color bitmap or ico file? I have the following so far:

BOOL CMyApp::OnInit()
{
    m_MyCursor = LoadCursor(IDC_MY_ICON_RES_ID);
}

BOOL CMyView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    ::SetCursor(theApp.m_MyCursor);
    return TRUE;
}

I'm not sure if loading from a 32x32 .ico file is appropriate. The above works with a .cur file. So how can I modify this to get some color in the cursor?

Thanks
Comment
Watch Question

Commented:
In Visual C++ .Net 2003:

- Open up the cursor resource in the resource editor
- Right-mouse in the editor window to bring up a large menu
- Near the bottom of the menu select "New Image Type", pick something that is not monochrome, such as 32x32, 16 colors
- Edit your cursor with fancy colors
- Right-mouse, select Current Cursor Image Types, drag across, select the monochrome bitmap. You should see your boring monochrome cursor again.
- Right-mouse, select "Delete Image Type", this deletes the monochrome bitmap
- When you save, your cursor will now contain only a color bitmap

Just rebuild and you will have it.

You can also import a cursor file with a color bitmap, that will work too.

The idea is similar in Visual C++ 6.0, although the resource editor is quite a bit different.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
mahesh1402IT Professional
Top Expert 2005

Commented:
You may also try LoadImage instead of LoadCursor.

However you need to delete the default monochrome device image like follows:

Open the cursor image, select monochrome device, click Image -> Delete Device Image.


Then you can add the WM_SETCURSOR handle, and modify the function as:

BOOL CMyView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
              ::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));    
              return TRUE;      
}

Then you can use your colored cursor

More Information Refer : Q135047 HOWTO: Use Resource Editor for 16-Color 32x32 Mouse Pointers

http://support.microsoft.com/support/kb/articles/q135/0/47.asp <==


MAHESH


Author

Commented:
Works perfectly, thanks.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.