Title:         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 checkbox. Its size can be
               altered but it has no caption or three-state style. 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,
and is said to be "highlighted", while the mouse is captured. When the
left mouse button is released, the highlight is removed. If the cursor
is over the control at that time, the state of the control is changed
from checked to unchecked or vice-versa.

When the standard control has the input focus, depressing the space bar
highlights the checkbox, and releasing it again removes the highlight
and changes the state of the control from checked to unchecked or
vice-versa.

The "CHECKBOX" 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, "CHECKBOX" controls can be packed closely into arrays and
other groupings.

A "CHECKBOX" 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, "CHECKBOX",
       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.

A "CHECKBOX" control can be put into a dialog box with the Borland
Resource Workshop, by selecting a custom control and then entering the
class name "CHECKBOX" instead of choosing one of the predefined classes.
Then edit the resulting .RC file as text and replace "BorCheck" with
"CHECKBOX" if necessary.

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

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

Like a standard checkbox control, a "CHECKBOX" control may be enabled
or disabled, it processes the BM_SETCHECK, BM_GETCHECK, BM_SETSTATE and
BM_GETSTATE 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 simpler control of the class "SCHECKBOX", which does not capture the
mouse and does not process the BM_SETSTATE and BM_GETSTATE messages, is
also available.

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

