home *** CD-ROM | disk | FTP | other *** search
- ValidEdit (tm)
- Self-Validating Edit Controls for Microsoft Windows
-
- Rolling Thunder Computing
- 20 Hilltop Terrace
- Woburn MA 01801 USA
- (617) 938-4326
-
-
- I. Introduction
-
- ValidEdit is a custom control for use with Microsoft
- Windows. It is a superclass of the EDIT class that can be
- set to accept or reject different types of keystrokes, for
- example, accepting numbers but rejecting letters. It
- improves your user interface by allowing the user of your
- programs to type into an edit control only input that is
- valid according to rules you specify.
-
- II. Business
-
- ValidEdit is a copyrighted software product of Rolling
- Thunder Computing. It is not in the public domain. You are
- permitted to evaluate this unregistered copy for 30 days, to
- copy it freely for backup purposes, and to distribute it
- freely to other users for them to evaluate. If you decide
- to continue using it after the 30-day evaluation period is
- up, you may obtain a registered copy without the initial
- dialog box, with free upgrades for one year, compatible with
- Microsoft and Borland dialog box editors, and with no end-
- user royalties, by mailing the enclosed license form with
- US$ 50 (MA residents add 5% sales tax) to: Rolling Thunder
- Computing, 20 Hilltop Terrace, Woburn MA 01801. Shipping is
- free in the United States and Canada, other countries write
- for current rates. Specify 3-1/2 inch or 5-1/4 inch
- diskettes. Your feedback is encouraged to Rolling Thunder
- Computing at the above address, or on Compuserve to David
- S. Platt, #73540,3430.
-
- III. Files
-
- ValidEdit comes with the following files:
-
- VALIDEDT.DLL A Windows 3.0 DLL containing the code for
- processing input to a ValidEdit box. This file should be
- placed in your path, so Windows can locate it.
-
- VALIDEDT.DOC This document.
-
- VALIDEDT.H A header file to be included in any C or .RC
- files that need to use ValidEdit controls. This file should
- be placed in your standard headers directory.
-
- VALIDEDT.LIC A license application for registering your
- copy of ValidEdit.
-
-
-
- IV. Using a ValidEdit Box
-
- ValidEdit is implemented as a Dynamic Link library.
- Your program may either load it explicitly with
- LoadLibrary(), or Windows will load it automatically when
- you first create a ValidEdit box. The former method is
- faster from the user's point of view, the latter method uses
- less memory.
-
- A ValidEdit box is created in the same manner as any
- other edit control box. You will generally want to put it
- in a dialog box template in your application's .RC file,
- such as:
-
- #include <validedt.h>
-
- SELECTPAGEBOX DIALOG PRELOAD MOVEABLE DISCARDABLE 22, 17, 140, 80
- CAPTION "PAGE SELECTION"
- STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | DS_SYSMODAL
- BEGIN
- CONTROL "", IDD_PAGENAME, VALIDEDIT_CLASS, WS_BORDER | WS_CHILD | WS_VISIBLE, 45, 30, 50, 15
- DEFPUSHBUTTON "OK" IDOK, 25, 50, 32, 14, WS_GROUP
- PUSHBUTTON "CANCEL" IDCANCEL, 83, 50, 32, 14, WS_GROUP
- END
-
-
- If you do it this way, you will need to set the validation
- parameters (see next section) explicitly in the dialog box
- procedure, as there is currently no way of setting the
- ExStyle parameters directly from a dialog box template.
-
- If you would rather create the ValidEdit box manually,
- we suggest you use CreateWindowEx, which will allow you to
- set the validation parameters (see next section) at creation
- time, such as:
-
- #include <validedt.h>
-
- hValidEdit = CreateWindowEx ( IVE_ALPHA, VALIDEDIT_CLASS,
- name, style, x, y, width, height, hParent, hMenu,
- hInstance, lpCreateStruc) ;
-
-
- V. Setting Validation Rule Parameters
-
- A ValidEdit box accepts or rejects characters according
- to rules that the user gives it. The rules are specified by
- setting various bits in the ValidEdit box's ExStyle DWORD.
- You must specify some rule; the default ExStyle is 0, which
- means no characters will be accepted. When the ValidEdit
- box rejects a character, it sends a message to its parent,
- informing the parent which character it has rejected (see
- next section for details on messages). The ValidEdit box
- checks its ExStyle anew every time it receives a character,
- so you can change validation rules without having to destroy
- and recreate the ValidEdit box. You set the flags by using
- SetWindowLong, thus:
-
- SetWindowLong (hValidEdit, GWL_EXSTYLE, IVE_ALPHA | IVE_OCTALDIGIT) ;
-
- Styles may be combined as desired without causing trouble,
- however, not all combinations make sense. The order in which
- a ValidEdit box applies its validation rules is:
-
- 1. Check for explicit exclusion (IVE_EXCLUDETHISLIST) of
- characters. If the newly-entered character is a member of
- this list, it is immediately rejected, no matter what other
- specified rules it might satisfy. In this way, you can, for
- example, accept all hex digits but 'B'. (WARNING: explicit
- exclusion and inclusion are case sensitive, so if you want
- to eliminate the hex value 0xB, you must explicitly exclude
- both 'B' and 'b'.)
-
- 2. Check for a second decimal point. If IVE_ONEDECPOINT is
- a specified style, the character is next checked to see if
- it is a decimal point, and, if so, whether the ValidEdit box
- already contains one. If it is and it does, the second
- decimal point is rejected.
-
- 3. After the first two tests specified above, all of the
- other rules are checked in an order which is not
- guaranteed. The first successful match of a character with
- a specified rule terminates the checking and causes the
- character to be accepted. Thus, if you specify both
- IVE_OCTALDIGIT and IVE_HEXDIGIT, values 8-F are guaranteed
- to be accepted all the time, so you might as well not bother
- with IVE_OCTALDIGIT.
-
- NOTE: To conform to expected edit box behavior, the
- backspace character (CTRL-H, 0x08) and the delete character
- (0x7F) are always accepted unless explicitly excluded.
-
- The valid styles are:
-
- IVE_HEXDIGIT: Hexadecimal digits, 0-9 and A-F, case
- insensitive.
-
- IVE_OCTALDIGIT: Octal digits, 0-7
-
- IVE_DECIMALDIGIT: Decimal digits, 0-9
-
- IVE_ALPHA: Alphabetic characters, A-Z, case insensitive
-
- IVE_ANYPUNCT: Punctuation characters, anything that
- satisfies the ANSI C macro ISPUNCT ().
-
- IVE_ONEDECPOINT: A maximum of one decimal point. Second
- decimal points are rejected. Useful for floating-point
- numbers.
-
- IVE_WHITESPACE: Whitespace characters, anything that
- satisfies the ANSI C macro ISSPACE ().
-
- IVE_ANYCNTRL: Characters entered with the CTRL key down,
- anything that satisfies the ANSI C macro ISCNTRL ().
-
- IVE_INCLUDETHISLIST: Any character that is a member of a
- string specified by the programmer. This string is
- specified by means of the WM_SETINCLUDESTRING message
- described in the next section. Checking of this string IS
- CASE SENSITIVE.
-
- IVE_EXCLUDETHISLIST: Any character that is NOT a member of
- a string specified by the programmer. This string is
- specified by means of the WM_SETEXCLUDESTRING message
- described in the next section. Checking of this string IS
- CASE SENSITIVE. This rule is always evaluated first, and takes
- precedence over all the others, even explicit inclusion using
- IVE_INCLUDETHISLIST.
-
- IVE_ALPHANUMERIC: Convenient combination of IVE_ALPHA and
- IVE_DECIMALDIGIT described above. All decimal digits 0-9
- and all letters A-Z, case insensitive.
-
- IVE_FLOATINGPOINT: Convenient combination of
- IVE_DECIMALDIGIT and IVE_ONEDECPOINT described above.
- Useful for entering floating-point numbers.
-
-
-
-
- V. Messages
-
- A ValidEdit control uses three custom messages in
- addition to all the normal messages supported by a stnadard
- edit control. These messages are defined in VALIDEDT.H.
- They are:
-
- IEVM_INVALIDCHAR
-
- This message is sent to you by your ValidEdit box when it
- rejects a character. The user has entered a character which
- does not conform to the validation rules specified in the
- ValidEdit box.
-
- wParam: child window ID of ValidEdit box
- lParam: LOWORD is child window handle of ValidEdit box
- HIWORD is rejected character
-
- IEVM_SETINCLUDESTRING
- IEVM_SETEXCLUDESTRING
-
- These two messages are sent by the programmer to the
- ValidEdit box, generally at initialization time. They set
- the strings containing the characters which the ValidEdit
- box will explicitly include or exclude, respectively. You
- may combine the two together, and also combine them with
- other validation rules, making (for example) a ValidEdit box
- that accepts all hex digits except 9, and also accepts the
- characters '$' and '*'.
-
- wParam: not used
- lParam: LPSTR, pointing to the string containing the
- characters to include or exclude. This string is copied into
- the edit control's own data area, so it need not be
- maintained by the calling function after successfully
- returning.
-
- returns: The length of the include/exclude string if
- successful, otherwise NULL.
-
- NOTE: The IVE_INCLUDETHISLIST and IVE_EXCLUDETHISLIST flags
- must be set in the ValidEdit box's ExStyle DWORD for
- inclusion or exclusion to occur. Sending the message and
- setting the strings is necessary, but not sufficient. If
- you want to temporarily disable inclusion and/or exclusion,
- you can simply turn the appropriate style bits off. This
- will not affect the storage of the inclusion/exclusion
- lists, which will function correctly as previously set when
- you turn the style bits back on.
-
-
-
-
-
- Trademarks of various software products are properties of
- their owners.