EN_KILLFOCUS AfxMessageBox [Moved]
-
I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.
modified on Friday, July 24, 2009 12:41 AM
-
I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.
modified on Friday, July 24, 2009 12:41 AM
Generally it is not a good idea to validate user input on focus loss, for example see here[^]. In the old times when i tried to do the same i ran into all kinds or troubles myself. If you can i recommend rethinking your validation system.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
-
I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.
modified on Friday, July 24, 2009 12:41 AM
-
Generally it is not a good idea to validate user input on focus loss, for example see here[^]. In the old times when i tried to do the same i ran into all kinds or troubles myself. If you can i recommend rethinking your validation system.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
Yes your right...I also know it that validation in kill focus is not a good idea....but still i have to do it because its an requirement... Please suggest be some idea to handle this situation....
-
Yes your right...I also know it that validation in kill focus is not a good idea....but still i have to do it because its an requirement... Please suggest be some idea to handle this situation....
I guess if it was easy to solve it wouldn't be a problem to validate on focus loss. You could try to check if the window who gets the focus belongs to your application or not, or maybe check if your aplication is the active application on the syatem or not and not display the message if it is not. Do these make any sense? How about a different aproach? Don't display a message box but change the errorous edit field's background color to red for example, and maybe have a static field or such placed somewhere on your dialog that explains to the user what is wrong with the edit field, maybe show the error message in a tooltip when the user points his mouse at the edit field. Or is the message box itself also a requirement?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
-
I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.
modified on Friday, July 24, 2009 12:41 AM
what u want to validate?