Using Your Own Cursor Shapes

To create and use your own cursor shapes, follow these steps:

1.Create the cursor shape itself by using the Image Editor.

2.Define the cursor in your resource script file by using the CURSOR statement.

3.Load the cursor by using the LoadCursor function.

4.Display the cursor using one of the techniques described in “Displaying the Cursor” on the next page.

The following sections explain each step.

Creating a Cursor Shape

The first step is to create the cursor shape itself. You do this by using the Image Editor, which lets you see an actual-size version of the cursor shape while you're editing it.

When you have created the cursor, save it in a cursor file. The recommended extension for cursor files is .CUR.

For information about using the Image Editor, see the Toolkit.

Adding the Cursor to Your Application Resources

Next, add a CURSOR statement to your resource script file. The CURSOR statement specifies the file that contains the cursor, and defines a name for the cursor. The application will use this cursor name when loading the cursor. The following is an example of a CURSOR statement:

bullseye CURSOR BULLSEYE.CUR

In this example, the name of the cursor is bullseye, and the cursor is in the file BULLSEYE.CUR.

Loading the Cursor Resource

In your application code, retrieve a handle to the cursor using the LoadCursor function. For example, the following code loads the cursor resource named bullseye and assigns its handle to the variable hCursor:

hCursor = LoadCursor(hInstance,(LPSTR) “bullseye”);

In this example, the LoadCursor function loads the cursor from the application's resources. The instance handle, hInstance, identifies the application's resources and is required. The name bullseye identifies the cursor. It is the same name given in the resource script file.