Quote:
Originally posted by gstercken
That's exactly what we call 'Dialog Data Validation', or DDV, for short.
No, "Dialog Data Validation" is one way of validating the data, but it is not the only way. You are entitled to always use DDV for data validation and it is good for you to suggest it as a possibility, but you are insisting that your way is the only correct way.
Quote:
Originally posted by gstercken
When doing the validation in DoDataExchange(), calling pDX->Fail() will do exactly what the OP requested (displaying a message box, leaving the dialog open etc.).
Is Wombat correct? Does DoDataExchange not validate for an empty string? If so, then DoDataExchange does nt do exactly what is asked for.
Quote:
Originally posted by gstercken
In addition, it does other useful things, like restoring the focus and the selection to the control where the input has to be corrected. When overriding OnOK, those things had to be implemented manually, too.
When overriding OnOK, a custom error message can be provided, and restoring the focus to the control is just one line of code.
Quote:
Originally posted by gstercken
Not overly complicated, of course, but it's not the designed way of doing validation, and it requires more code (an estimated 3x more).
Whose estimate?
I really think that not everyone agrees that DDV is the only solution.
Quote:
Originally posted by gstercken
As already mentioned, it is unsafe towards further extensions. When changing the dialog to modeless or to a property sheet, the validation code implemented in OnOK would have to be modified, copied or moved. Failing to remember that would lead to subtle errors (like the validation taking place when clicking OK, but not when clicking Apply and then Cancel, or when switching to a different property page.)
These are all typical consequences of making modifications to software. There are many things that can be overlooked if a person does not know what to do or if they simply overlook something. It happens. However the modifications relevant here would not be required when converting to modeless; other changes would definitely be required. I don't know what the changes would be required when converting to a property sheet, but I suspect that other changes would be substantial.