A Sample Application: Cursor

This sample application, Cursor, illustrates how to incorporate cursors and how to use the mouse and keyboard in your applications. It illustrates the following:

Using a custom cursor as the class cursor

Showing the hourglass cursor during a lengthy operation

Using the mouse to select a portion of the client area

Using the keyboard to move the cursor

To create the Cursor application, copy and rename the source files of the Generic application, then make the following modifications:

1.Add a CURSOR statement to your resource script file.

2.Add new variables.

3.Load the custom cursor and use it to set the class cursor in the initialization function.

4.Prepare the hourglass cursor.

5.Add a lengthy operation to the window function (for simplicity, use the ENTER key to trigger the operation).

6.Add the WM_LBUTTONDOWN, WM_MOUSEMOVE, and WM_LBUTTONUP cases to the window function to support selection.

7.Add the WM_KEYDOWN case to the window function to support keyboard-controlled cursor movement.

8.Add the WM_PAINT case to the window function to redraw the client area after it has been invalidated.

9.Add BULLSEYE.CUR to the project file.

10.Build and run the application.

This sample assumes that your system has a mouse; if your system does not, the application might not operate as described. However, it is a fairly straightforward task to adjust the sample to work with both the mouse and the keyboard or with only the keyboard.

NOTE:

Rather than typing the code provided in the following sections, you might find it more convenient to simply examine and build the sample source files provided on the sample disks.