Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!mips!zaphod.mps.ohio-state.edu!wuarchive!udel!brahms.udel.edu!garrett From: garrett@chopin.udel.edu (Joel Garrett) Newsgroups: comp.windows.ms.programmer Subject: Can I use EN_KILLFOCUS for field-checking? Message-ID: <17176@chopin.udel.edu> Date: 23 May 91 13:36:06 GMT Organization: University of Delaware Lines: 31 I want to be able to error check the edit controls in a dialog box, ie if they enter something that isn't a valid floating-point number, I want to be able to keep the user in that field until they enter a valid entry. To do this, I tried using the EN_KILLFOCUS message to let me know when the user was leaving a certain input field, at which time I could check the contents of that field and if they weren't ok, I'd do somthing like this: MessageBeep(0); SetFocus(hwndCtrl); SendDlgItemMessage(hDlg, nCtrlID, EN_SETSEL, 0, MAKELONG(0,32767)); Where hwndCtrl is a handle to the edit control with the bad value in it (returned as part of the EN_KILLFOCUS message), and nCtrlID is the control ID of the same edit control (why is this also included with the EN_KILLFOCUS message, actually I guess the question is why both of these are returned, when the handle could just as easily be gotten via GetDlgItem()...) When I try doing this, the above section of code seems to get executed Ok, but then it looks as though things get confused, as if I try to tab out of an invalid field, the beep and selection take place but then the input focus seems to go to the next field in the tab order, but things act screwey with regard to how the cursor tracks in the fields, it almost seems as though both the old and new fields have "some" of the input focus. Does anybody have any suggestions for a better way of doing this? Thank you very much in advance... Joel garrett@chopin.udel.edu