Title:         Simplified Windows Checkbox Control
Author:        Philip J. Erdelsky, 75746.3411@compuserve.com
Language:      Turbo C/C++ 3.1 for Windows
Platform       Windows 3.1
Portability:   Other Windows C++ compilers, with slight changes
Restrictions:  Public domain, no restrictions on use
Date:          January 10, 1995
Keywords:      Windows Custom Control, Checkbox

Abstract:      A windows custom control for a simplified checkbox. Its
               size can be altered but it has no caption or three-state
               style and does not capture the mouse. The focus rectangle
               surrounds the box. C++ source code only; no VBX file.

The standard Windows 3.1 checkbox control consists of a square of fixed
size, with a caption to the right or left. The checkbox may be checked,
in which case an "X" is inscribed in the square, or unchecked, in which
case inside of the square is left blank. A three-state checkbox also has
an intermediate state in which the inside of the square is gray. The
focus rectangle surrounds the caption, not the box.

The standard control also "captures" the mouse. If the left mouse button
is depressed and held down while the cursor is over the control, the
mouse can be moved elsewhere without affecting other controls, as long
as the left mouse button is held down. The checkbox itself is darkened
while the mouse is captured.

The "SCHECKBOX" control has no caption. (If a caption is needed, a
static text control can be used for that purpose.) The focus rectangle
surrounds the box. The box itself is sized to fit into the rectangle
provided for the control. The control has no three-state style.

Therefore, "SCHECKBOX" controls can be packed closely into arrays and
other groupings.

Since an "SCHECKBOX" control is highly simplified, it also provides a
good illustration of the basic C++ code for custom Windows controls.

An "SCHECKBOX" control can be put into a dialog box by including a line
of the following form in the appropriate place in the resource (.RC)
file:

     CONTROL 0, control-id, "SCHECKBOX",
       WS_CHILD | WS_VISIBLE | WS_TABSTOP, x, y, width, height

Since the control is square, the height and width should be equal. The
control will be sized to fit into the specified square. If the height
and width are not equal, the control will still be square, but it will
fill only the top or left portion of the specified rectangle.

An "SCHECKBOX" control can be put into a dialog box with the Borland
Resource Workshop, by selecting a custom control and then entering the
class name "SCHECKBOX" instead of choosing one of the predefined classes.

An "SCHECKBOX" control may also be created dynamically with an
appropriate call on CreateWindow().

The accompanying code in SCHECKBO.CPP must be compiled and linked with
the application.

Like a standard checkbox control, an "SCHECKBOX" control may be enabled
or disabled, it processes the BM_SETCHECK and BM_GETCHECK messages, and
it may gain or lose the input focus. It also sends a BN_CLICKED message
to its parent when the user adds or removes the "X". Other features of
the standard checkbox control are not supported.

A more complex control of the class "CHECKBOX", which captures the mouse
and processes the BM_SETSTATE and BM_GETSTATE messages, is also
available.

The files SCHETEST.CPP and SCHETEST.RC contain a simple test program
that uses several "SCHECKBOX" controls of various sizes.

