Handling KillFocus

Started by Mark Strickland, July 26, 2005, 04:29:08 PM

Previous topic - Next topic

Mark Strickland

I have a Post Process edit on some fields to check various things and "fix up" the user input.  I use it to add dashes to phone numbers, make sure the value of a TextBox is unique (only one of the value allowed in the DB), etc.  The post edit is in the KillFocus event.  If things are "bad" I pop up a message box with a choice to fix or ignore (sometimes ignoring is not an option depending on which field).

I have a global flag that I put in front of each Post Edit check that if it is set then I skip the Post Edit.  I set the flag specifically in a Custom Event on the main form to catch closing the main form (program exit) to not perform any possible Post Edits caused by a KillFocus.  It is also set in various other places to keep the Post Edit from happening.

My problem -- I cannot set this flag from a button event on the same form to avoid the Post Edit on the currently focused TextBox.  The button is a CLEAR IT ALL START THE FORM OVER so the Post Edit no longer needs to apply.  The KillFocus on the TextBox fires first before the button SetFocus.  I know that is totally logical.

I am hoping there a way to detect in the custom event on the form that the button has been pressed BEFORE the KillFocus actually fires on the TextBox?  If I can catch it there then I can set the flag and the Post Edit will be skipped.

Along the same lines  --- what is the best Windows SDK / API programming book that would define all of the message types?

Thanks.