LoadCursor

Syntax

HCURSOR LoadCursor(hInstance,lpCursorName)

This function loads the cursor resource named by the lpCursorName parameter from the executable file associated with the module specified by the hInstance parameter. The function loads the cursor into memory only if it has not been previously loaded. Otherwise, it retrieves a handle to the existing resource.

Parameter Type/Description  

hInstance HANDLE Identifies an instance of the module whose executable file contains the cursor.  
lpCursorName LPSTR Points to a character string that names the cursor resource. The string must be a null-terminated character string.  

Return Value

The return value identifies the newly loaded cursor if the function is successful. Otherwise, it is NULL.

Comments

The LoadCursor function returns a valid cursor handle only if the lpCursorName parameter identifies a cursor resource. If lpCursorName identifies any type of resource other than a cursor (such as an icon), the return value will not be NULL, even though it is not a valid cursor handle.

Use the LoadCursor function to access the predefined cursors used by Windows. To do this, the hInstance parameter must be set to NULL, and the lpCursorName parameter must be one of the following values:

Value Meaning  

IDC_ARROW Standard arrow cursor.  
IDC_CROSS Crosshair cursor.  
IDC_IBEAM Text I-beam cursor.  
IDC_ICON Empty icon.  
IDC_SIZE Loads a square with a smaller square inside its lower-right corner.  
IDC_SIZENESW Double-pointed cursor with arrows pointing northeast and southwest.  
IDC_SIZENS Double-pointed cursor with arrows pointing north and south.  
IDC_SIZENWSE Double-pointed cursor with arrows pointing northwest and southeast.  
IDC_SIZEWE Double-pointed cursor with arrows pointing west and east.  
IDC_UPARROW Vertical arrow cursor.  
IDC_WAIT Hourglass cursor.  

The lpCursorName parameter can contain a value created by the MAKEINTRESOURCE macro. If it does, the ID must reside in the low-order word of lpCursorName, and the high-order word must be set to zero.