I am trying to change the mouse cursor and write the code below but doesn't work.
It seems IDC_CURSOR_WHITE
should be put into a rc file. I tried and failed. At last I came here seeking your guidance. Help! Thanks.
IDC_CURSOR_WHITE IDC_CURSOR_BLACK not
hWhiteCursor = ::LoadCursor(hInstance, (LPCTSTR)IDC_CURSOR_WHITE);
hBlackCursor = ::LoadCursor(hInstance, (LPCTSTR)IDC_CURSOR_BLACK);
case WM_LBUTTONDOWN:
if ((type = ++type % 2) == 0)
SetCursor(hWhiteCursor);
else
SetCursor(hBlackCursor);
break;
case WM_SETCURSOR
return 0;
PS: The rc file code. And the error is mouse cousor not defined.
// Microsoft Visual C++ generated resource script.
//
#include "resource."
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.\0"
END
3 TEXTINCLUDE
BEGIN
"\r\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Cursor
//
IDC_CURSOR_WHITE CURSOR "cursor1.cur"
IDC_CURSOR_BLACK CURSOR "cursor2.cur"
#endif // resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
From the snippets you posted, in the code you are loading the cursors using IDC_CURSOR_WHITE
and IRC_CURSOR_BLACK
, but you are including them in the .rc file as IDC_CURSOR1
and IDC_CURSOR2
.