Control validating slowdating
The DDV mechanism is far too primitive to be useful.It only validates on the OK button (or, more specifically, on the Update Data that accompanies it), which delays the validation until far too late.In such a case, you would more likely do the validation on the WM_KILLFOCUS (On Kill Focus) event.I also find it particularly annoying that I am allowed to click the OK button when there is an error; this violates the basic principles of GUI design.So DDV is not only hard for the user to use, it actually violates the GUI design guidelines since normally you must click a button which is not actually valid to click before the DDV mechanism can be invoked! But the goal is not to make applications easy to program as much as it is to make applications easy to use.It also issues error messages that are related to the representation in the program, not to the problem domain.I have thus avoided this toy mechanism and written my own validation code.I believe my techniques contribute significantly to the latter.
This particular example is useful as it illustrates several useful techniques.
These include I have used all of these techniques in some form or other in building very informative, user-oriented validation methods.
The first thing I include is a validating edit control.
This particular control solves a problem many users ask for: an edit control that validates floating-point input.
However, you can replace the FSM with one that validates dates, times, Social Security Numbers, or any other textual form you can parse.
The validation does not have to be limited to simple parsing, although it is clear from the fact that every change initiates a validation that you do not want to do some sort of database lookup on every character.