Link to home
Start Free TrialLog in
Avatar of minnirok
minnirok

asked on

color mouse cursor

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
ASKER CERTIFIED SOLUTION
Avatar of wayside
wayside

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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


Avatar of minnirok
minnirok

ASKER

Works perfectly, thanks.