HOW TO: detect a keypress 
Author Message
 HOW TO: detect a keypress

Hi,

How would I have my dialog detect a keypress. Suppose a user types something
inside an edit box and clicks on Cancel; I would want my dialog to prompt
the user if he/she is sure about discarding the entered data. I tried
WM_KEYDOWN and set a BOOL variable which my OnCancel checks before exiting.
But WM_KEYDOWN doesn't get passed when I press a key, what's the approprite
message that gets passed when a user presses a key?

Thanks,

Lee



Fri, 06 Aug 2004 01:31:52 GMT  
 HOW TO: detect a keypress
Well, the EDIT control will send its parent an EN_CHANGE notification when, "...the user has taken
an action that may have altered [the] text...", maybe you could make use of that. Or maybe in your
OnCancel handler you could just query the control for its text or maybe just its text length and
make your decision there.
Jeff...
Quote:

> Hi,

> How would I have my dialog detect a keypress. Suppose a user types something
> inside an edit box and clicks on Cancel; I would want my dialog to prompt
> the user if he/she is sure about discarding the entered data. I tried
> WM_KEYDOWN and set a BOOL variable which my OnCancel checks before exiting.
> But WM_KEYDOWN doesn't get passed when I press a key, what's the approprite
> message that gets passed when a user presses a key?

> Thanks,

> Lee



Fri, 06 Aug 2004 02:06:03 GMT  
 HOW TO: detect a keypress
Maybe you can do it in PreTranslateMessage

--
My Homepage: http://franz.uhome.net
My icq no.: 23419712


Quote:
> Hi,

> How would I have my dialog detect a keypress. Suppose a user types something
> inside an edit box and clicks on Cancel; I would want my dialog to prompt
> the user if he/she is sure about discarding the entered data. I tried
> WM_KEYDOWN and set a BOOL variable which my OnCancel checks before exiting.
> But WM_KEYDOWN doesn't get passed when I press a key, what's the approprite
> message that gets passed when a user presses a key?

> Thanks,

> Lee



Fri, 06 Aug 2004 02:25:39 GMT  
 HOW TO: detect a keypress
thanks all! I found that CEdit class has a member function GetModify which
returns a 0 is text is unchanged.


Quote:
> Hi,

> How would I have my dialog detect a keypress. Suppose a user types
something
> inside an edit box and clicks on Cancel; I would want my dialog to prompt
> the user if he/she is sure about discarding the entered data. I tried
> WM_KEYDOWN and set a BOOL variable which my OnCancel checks before
exiting.
> But WM_KEYDOWN doesn't get passed when I press a key, what's the
approprite
> message that gets passed when a user presses a key?

> Thanks,

> Lee



Fri, 06 Aug 2004 04:36:54 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Detecting A Keypress

2. Detecting keypress

3. HELP! Keypress detect

4. Detecting a keypress

5. How To Detect KeyPress.

6. Detecting keypress when the focus is on CButton

7. Detecting delete keypress in OnChar

8. Detect keypress in dialog-based

9. combobox and keyPress Event

10. Convert keypress to upper case

11. object sender keypress (c# newbie)

12. Tab KeyDown-KeyPress trapping

 

 
Powered by phpBB® Forum Software