6.1.1 Using Built-In Cursor Shapes

Windows provides several built-in cursor shapes. These include the arrow, hourglass, I-beam, and cross-hair cursors. Most of the built-in cursor shapes have specialized uses. For example, the I-beam cursor is typically used when the user is editing text, and the hourglass cursor is used to indicate that a lengthy operation is in progress, such as reading a disk file.

To use a built-in cursor, use the LoadCursor function to retrieve a handle of the built-in cursor. The first argument to LoadCursor must be NULL (indicating that a built-in cursor is requested); the second argument must specify the cursor to load. The following example loads the I-beam cursor, IDC_IBEAM, and assigns the resulting cursor handle to the variable hCursor.

hCursor = LoadCursor(NULL, IDC_IBEAM);

Once an application has loaded a cursor, it can use the cursor; for example, it could display the I-beam cursor when the user is currently editing text. For information about how to display the cursor, see Section 6.2, “Displaying a Cursor.”