color mouse cursor

Posted on 2006-04-05
Last Modified: 2013-11-20

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?

Question by:minnirok
    LVL 14

    Accepted 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.
    LVL 22

    Expert Comment

    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 <==


    LVL 7

    Author Comment

    Works perfectly, thanks.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Error on moodle after upgrade 3 95
    Generic progress indicator 6 107
    countEvens challenge 2 48
    Detect file exist or not 3 42
    In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
    Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now