mike_marquet
asked on
Using color cursors !
How can I use colored cursors in my MFC application ?
I have try this but no cursor are loaded :
IDC_MYCOLORCURSOR is a 16 color cursor defined in the
resource.
BOOL CMyDialog::OnSetCursor(CWn d *pWnd, UINT nHitTest, UINT message)
{
HCURSOR hCursor = LoadCursor(IDC_MYCOLORCURS OR);
if (hCursor) // hCursor is always NULL. Why ?
{
::SetCursor(hCursor);
return TRUE;
}
return CDialog::OnSetCursor(pWnd, nHitTest,m essage);
}
I have also try this :
static HANDLE g_hCursor;
BOOL CMyDialog::OnInitDialog()
{
......
g_hCursor = LoadImage(AfxGetInstanceHa ndle(), "IDC_MYCOLORCURSOR", IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
// g_hCursor is always NULL (Also when the cursor is monochrome). Why ?
......
}
BOOL MyDialog::DestroyWindow()
{
if (g_hCursor) DestroyCursor((HCURSOR)g_h Cursor);
....
}
BOOL CMyDialog::OnSetCursor(CWn d *pWnd, UINT nHitTest, UINT message)
{
HCURSOR hCursor = (HCURSOR)g_hCursor;
if (hCursor)
{
::SetCursor(hCursor);
return TRUE;
}
return CDialog::OnSetCursor(pWnd, nHitTest,m essage);
}
I have try this but no cursor are loaded :
IDC_MYCOLORCURSOR is a 16 color cursor defined in the
resource.
BOOL CMyDialog::OnSetCursor(CWn
{
HCURSOR hCursor = LoadCursor(IDC_MYCOLORCURS
if (hCursor) // hCursor is always NULL. Why ?
{
::SetCursor(hCursor);
return TRUE;
}
return CDialog::OnSetCursor(pWnd,
}
I have also try this :
static HANDLE g_hCursor;
BOOL CMyDialog::OnInitDialog()
{
......
g_hCursor = LoadImage(AfxGetInstanceHa
// g_hCursor is always NULL (Also when the cursor is monochrome). Why ?
......
}
BOOL MyDialog::DestroyWindow()
{
if (g_hCursor) DestroyCursor((HCURSOR)g_h
....
}
BOOL CMyDialog::OnSetCursor(CWn
{
HCURSOR hCursor = (HCURSOR)g_hCursor;
if (hCursor)
{
::SetCursor(hCursor);
return TRUE;
}
return CDialog::OnSetCursor(pWnd,
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Create 256 color icon resource with VC.
HCURSOR cursor = (HCURSOR)( AfxGetApp()->LoadIcon(IDI_ ICON256) );
SetCursor( cursor );
HCURSOR cursor = (HCURSOR)( AfxGetApp()->LoadIcon(IDI_
SetCursor( cursor );
ASKER
When I create a color cursor whith the workshop (for example, an 16 colors cursor) and I load this cursor with your method, the cursor never appears.
I must also tell that whith the workshop, when I use for example the red color and then an other color, all colors became black.
How must I proceed to create a color cursor with the workshop of visual C++ 5.0 ?