>but I can't keep the user from tabbing away or clicking on another control, leaving the >invalid data in place.
By the time you get WM_COMMAND/EN_KILLFOCUS the user is already out of the field.
You can do what you want to do here by subclassing, picking off the Tab key and if the user is not allowed to experience the default behavior of <TAB>, eating the WM_CHAR message by not passing it to the default handler.
Alternately, you can avoid the need to subclass by POSTing a message to yourself to set the focus. Because you post (vs send) this message it's turn won't come until all the 'regular' activity associated with this keystroke has been processed.
Eg
MCM
By the time you get WM_COMMAND/EN_KILLFOCUS the user is already out of the field.
You can do what you want to do here by subclassing, picking off the Tab key and if the user is not allowed to experience the default behavior of <TAB>, eating the WM_CHAR message by not passing it to the default handler.
Alternately, you can avoid the need to subclass by POSTing a message to yourself to set the focus. Because you post (vs send) this message it's turn won't come until all the 'regular' activity associated with this keystroke has been processed.
Eg
Code:
%PWM_SETMYFOCUS = %WM_USER + 1 ... CASE %WM_COMMAND/EN_KILLFOCUS if Bad_Data THEN DIALOG POST CB.HNDL, %PWM_SETMYFOCUS, ID_OF_CONTROL, %NULL CASE %PWM_SETMYFOCUS CONTROL SET FOCUS CB.HNDL, CB.WPARAM
Comment