A SERVICE OF

logo

instead override Lookup. TStringLookupValidator class is an instance class
based on TLookupValidator.
TStringLookupValidator is a working example of a lookup validator; it
String lookup
compares the string passed from the edit control with the items in a string
validator class
list. If the passed-in string occurs in the list, IsValid returns TRUE. The
constructor takes only one parameter the list of valid strings:,
TStringLookupValidator(TSortedStringArray* strings);
TSortedStringArray is defined as
typedef TSArrayAsVector<string> TSortedStringArray;
T use a different string list after constructing the string lookup validatoro ,
use member function NewStringList, which disposes of the old list and
installs the new list.
TStringLookupValidator overrides Lookup and Error. Lookup returns TRUE if
the passed-in string is in the list. Error displays a message box indicating
that the string is not in the list.
Picture validators compare the string entered by the user with a “picture”
Picture validator
or template that describes the format of valid input. The pictures used are
class
compatible with those used by Borland’ Paradox relational database tos
control user input. Constructing a picture validator requires two
parameters: a string holding the template image and a Boolean value
indicating whether to automatically fill-in the picture with literal
characters:
TPXPictureValidator(const char far* pic, BOOL autoFill=FALSE);
TPXPictureValidator overrides Error, IsValid, and IsValidInput, and adds a
new member function, Picture. Error displays a message box indicating
what format the string should have. IsValid returns TRUE only if the
function Picture returns TRUE; thus you can derive new kinds of picture
validators by overriding only the Picture member function. IsValidInput
checks characters as the user enters them, allowing only those characters
permitted by the picture format, and optionally filling in literal characters
from the picture format.
Here is an example of a picture validator that is being constructed to accept
social security numbers:
edit->SetValidator(new TPXPictureValidator("###-##-####"));
Picture syntax is fully described under TPXPictureValidator member
function Picture in the ObjectWindows Reference Guide.
Chapter 14, Validator objects
329