[comp.windows.ms] Error checking in Edit boxes.

mms00786@uxa.cso.uiuc.edu (07/04/90)

Hello!

I am in the process of writing a fairly simple dialog box function, and need
some help with that. To make it simple, I'll simplify the dialog box so it 
has only one edit box, one other control, an OK button and a Cancel button.
The value in the edit box is constrained. What I want to do is this : if
the user types in an invalid value, I want to emit a beep. Currently, I do
this when I get an EN_KILLFOCUS message from the control. However, I do not
want to beep when the user has either hit the ESC key or pressed the ESC
or Cancel button. How do I know, when I get the EN_KILLFOCUS, whether it is
due to the pressing of the Cancel button or the ESC key?

(I think that should be WM_KILLFOCUS, but you get the idea).

Thanks for any input!

Milan
.

kfort@shumv1.ncsu.edu (Ken Fort) (07/05/90)

In article <118500037@uxa.cso.uiuc.edu> mms00786@uxa.cso.uiuc.edu writes:
>
>Hello!
>
>I am in the process of writing a fairly simple dialog box function, and need
>some help with that. To make it simple, I'll simplify the dialog box so it 
>has only one edit box, one other control, an OK button and a Cancel button.
>The value in the edit box is constrained. What I want to do is this : if
>the user types in an invalid value, I want to emit a beep. Currently, I do
>this when I get an EN_KILLFOCUS message from the control. However, I do not
>want to beep when the user has either hit the ESC key or pressed the ESC
>or Cancel button. How do I know, when I get the EN_KILLFOCUS, whether it is
>due to the pressing of the Cancel button or the ESC key?
>
>(I think that should be WM_KILLFOCUS, but you get the idea).
>
>Thanks for any input!
>
>Milan
>.

Milan,

What if you try keying off of WM_CHAR messages instead?  Check the value of
input from the Edit Control as it comes in through each keystoryke.
--
  |``````````````````````````````````````````````````````````````````````````|
  | Ken Fort       kfort@shumv1.ncsu.edu          N. C. State University     |
  |--------------------------------------------------------------------------|

mms00786@uxa.cso.uiuc.edu (07/05/90)

Ref: Keying off of WM_CHAR messages.

Perhaps I wasn't very clear in my first post. The edit box in my dialog
box must have a valid value, except possibly when the user types in an
invalid value and then directly hits the cancel button. For example,
suppose 32 is an invalid entry. The user types in 32, then hits "OK".
The edit box should beep, and redirect focus to itself. Suppose the
user types in 32, then hits "Cancel". This is perfectly acceptable,
and there should be no beep, nothing. So, how do I find out from within
the edit box (or possibly somewhere else), when to check for a valid entry?

I have discovered a further complication : There *is* a difference between
hitting the "OK" button and pressing Enter. (likewise between Esc and Cancel)
The difference is that when you hit the Enter or Esc key, the current
dialog control never loses input focus at all, even though the dialog
function gets a IDOK or IDCANCEL message. Its very frustrating, because
I don't even get a chance to do any error checking, the dialog box is simply
swept out from under my feet!

Please, any pointers or any sample code on how to implement an error checking
edit control will be very much appreciated!

Thanks.

Milan
.