Create a new single-document project; add WM_SETCURSOR message processing function to the visual class;
Set the mouse pointer to IDC_CROSS, which is predefined by the system, a cross shape; when LoadCursor loads the system predefined cursor, the first parameter is NULL;
Pre-defined, waiting for the cursor; some computers are in the shape of an hourglass, and some are in the shape of a circle;
The system predefined cursors are as follows;
IDC_APPSTARTING standard arrow and small hourglass
IDC_ARROW standard arrow
IDC_CROSS cross cursor
IDC_HAND Windows 98/Me, Windows 2000/XP: Hand
IDC_HELP standard arrow and question mark
IDC_IBEAM
IDC_ICON Obsolete for applications marked version 4.0 or later.
IDC_NO prohibition circle
IDC_SIZE Obsolete for applications marked version 4.0 or later. Use IDC_SIZEALL.
IDC_SIZEALL Four-way arrows point east, west, south, and north
IDC_SIZENESW Double arrows point northeast and southwest
IDC_SIZENS Double arrows point north-south
IDC_SIZENWSE Double arrows point northwest and southeast
IDC_SIZEWE Double arrows point east-west
IDC_UPARROW Vertical Arrow
IDC_WAIT hourglass, under Windows7 system, it will be displayed as a circle of choice to indicate waiting
Draw an icon by yourself; ID is IDI_ICON1;
The following code sets the mouse pointer to IDI_ICON1, the code will not be wrong, but the cursor will not be displayed;
Insert a cursor; Cursor;
Draw it yourself; its ID is IDC_CURSOR1;
The following code sets the mouse pointer to IDC_CURSOR1, run the program, the mouse pointer is empty;
Load a custom cursor, the first parameter cannot be empty, as shown in the figure below; then the cursor comes out and moves with the mouse;
//HCURSOR hCur = LoadCursor( NULL , IDC_CROSS ) ;
//HCURSOR hCur = LoadCursor( NULL , IDC_WAIT ) ;
HCURSOR hCur = LoadCursor( AfxGetInstanceHandle() , MAKEINTRESOURCE(IDC_CURSOR1) ) ;
::SetCursor(hCur);
return true;