6.3 Using the Cursor with the Mouse

With a typical Windows application, the user performs many types of tasks by using a mouse—for example, choosing commands from a menu, selecting text or graphics, or directing scrolling operations. For most of these tasks, Windows automatically handles the mouse input; for example, when the user chooses a menu command, Windows automatically sends the application a message that contains the command identifier.

The application, however, handles one common task itself: the user's selecting information within the client area. So that the user can select this information (by using the mouse), the application must perform the following tasks:

Start processing the selection.

When the user presses the mouse button to start selecting information, the application must note the location of the cursor and temporarily capture all mouse input to ensure that other applications do not interfere with the selection process.

Provide visual feedback during the selection.

As the user drags the mouse across the screen, the application should show the user what information is currently being selected. For example, some applications highlight selected information; others draw a dotted rectangle around it.

Complete the selection.

When the user releases the mouse button, the application must note the final location of the cursor and signal the end of the selection process.

When the selection process is complete, the user can then choose an action to perform on the selected information. For example, when using a word-processing application, the user might select several words, then choose a command that changes the selected text to a different font. The following sections discuss each step in more detail and explain how to let the user select graphics in a window's client area.

Note:

The mouse is just one of many possible pointing devices. Other pointing devices such as graphics tablets, joysticks, and light pens may operate differently but still provide input identical to that of a mouse. The following examples can also be used with these devices. Remember that when a pointing device is present, Windows automatically controls the position and shape of the cursor as the user moves the pointing device.