Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
This control is the computer equivalent of all those little “Check All that Apply” spaces on paper forms. It’s useful for items that have two states—“it is” or “it ain’t.”
Use check boxes for items that fit the “this is”/”this isn’t” division. If you can’t think of a word or short phrase that can be preceded by “is” or “is not” to indicate the state of the check box, then it’s probably not the right control. For example, a check box is great for distinguishing between Active and Inactive (“is active”/”is not active” makes sense), but lousy for specifying gender (“is male”/”is not male” sounds weird). For those cases where a check box won’t do, consider an option group instead.
Having said that, we now have to tell you that check boxes in Visual FoxPro have three possible values. In the immortal words of George Carlin, “Why are there three?”
Actually, it’s for a pretty good reason. There are cases where the answer to the “is/is not” question is “I dunno.” With Visual FoxPro, you can actually handle that case. (However, the only way for the user to actually enter an “I don’t know” value is by pressing CTRL+0. Not only is this totally non-intuitive, but pressing CTRL+0 on a field that doesn’t accept nulls generates an error.)
“I don’t know” is the layman’s term for null, which is one of the nicer additions in Visual FoxPro. The Value of a check box can be .F., .T. or .NULL. (or, if you have a C background, 0, 1, or 2).
Property |
Value |
Purpose |
Alignment |
Numeric |
Determines which side of the caption the actual box is on. |
AutoSize |
Logical |
Determines whether the check box resizes itself to the size of its caption and picture. |
Caption |
Character |
The text that appears next to the check box. |
Picture, DownPicture, DisabledPicture |
Character |
The file names of pictures that appear on a graphical check box. Picture is used when the box is unchecked. DownPicture is used when the box is checked. DisabledPicture is used when the check box is disabled. If DownPicture or DisabledPicture is omitted, Picture is used for those states as well. |
SpecialEffect |
Numeric |
Determines the physical appearance of the check box: 3-D (0); Plain (1), meaning flat; Hot Tracking (2), meaning flat until the mouse is over it or it gets focus. The Hot Tracking value works only for graphical check boxes (Style=2). For standard check boxes, choosing Hot Tracking is the same as choosing Plain. |
Style |
Numeric |
Determines whether the check box is textual or graphical. A graphical check box shows both the picture and the caption. |
Another pleasant, though somewhat confusing, addition in Visual FoxPro is graphical check boxes. These things look like buttons, but when you click them, they stay down. (The buttons on the main VFP toolbar for the Command Window and Data Session Window are really check boxes.)
Like the other controls, starting in VFP 7, check boxes have the MouseEnter and MouseLeave events, which give you better opportunities to respond to mouse movements.
* Set up a CheckBox subclass that's
* right-aligned and autosized and
* displays a message when clicked.
DEFINE CLASS RightCheck AS CheckBox
Alignment = 1
AutoSize = .T.
PROCEDURE Click
WAIT WINDOW "You called?" NOWAIT
ENDPROC
ENDDEFINE
Alignment, AutoSize, Caption, DisabledPicture, DownPicture, MouseEnter, MouseLeave, OptionGroup, Picture, SpecialEffect, Style