[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 585
  • Last Modified:

color mouse cursor


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)
    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?

1 Solution
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.
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)
              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 <==


minnirokAuthor Commented:
Works perfectly, thanks.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now