The mouse is a hardware device that lets the user move the cursor and enter simple input by pressing a button. In a typical Windows application, the user performs many types of tasks with the 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 ID.
However, one common task, selection of information within the client area, must be handled by the application itself. In order to let the user select such information 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.
While 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, in a word processor, 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 system 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 be used with these devices as well. 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.