A Sample Library: Select

This sample library contains functions that you can use to carry out selections by using the mouse. The functions are based on the graphics selection method described in Chapter 18, “The Cursor, the Mouse, and the Keyboard.” These functions provide two kinds of selection feedback: a box that shows the outline of the selection, and a block that shows the entire selection inverted. The library exports the following functions:

StartSelection

Starts the selection and initializes the selection rectangle. When selecting with the mouse, you call this function when you receive a WM_LBUTTONDOWN message.

UpdateSelection

Updates the selection box or block. When selecting with the mouse, you call this function when you receive a WM_MOUSEMOVE message.

EndSelection

Ends the selection and fills in the selection rectangle with the final selection dimensions. When selecting with the mouse, you call this function when you receive a WM_LBUTTONUP message.

ClearSelection

Clears the selection box or block from the screen and empties the selection rectangle.

The selection rectangle is a RECT structure that the application supplies and the library functions fill in. The coordinates given in the rectangle are client coordinates.

To create this library you need to create several files:

File Contents

SELECT.C The C-language source for selection functions
SELECT.DEF The module-definition file for the Select library
SELECT.H The include file for the Select library
SELECT.MAK The project list for the Select library
SELECT.LIB The import library for the Select library

The Select library does not have an initialization file because the functions do not use a local heap and because no other initialization is necessary.

NOTE:

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