Detecting keypress when the focus is on CButton 
Author Message
 Detecting keypress when the focus is on CButton

Hi group,
i'm writing an application where i inserted some CButton(-subclassed).
I need to handle a keypress when the focus is over these buttons, into
the main window (it is a dialog).
Up to now, if i press function keys (and the focus in on a button) i don't
receive any message on the dialog: which event must i handle to do this ?

Thanks a lot  !
Regards
--
Stefano Mora

(remove *)



Sun, 11 Sep 2005 12:08:31 GMT  
 Detecting keypress when the focus is on CButton

Quote:
>i'm writing an application where i inserted some CButton(-subclassed).
>I need to handle a keypress when the focus is over these buttons, into
>the main window (it is a dialog).
>Up to now, if i press function keys (and the focus in on a button) i don't
>receive any message on the dialog: which event must i handle to do this ?

Stefano,

2 possible ways to go:

1. Try deriving a class from CButton and handling the WM_KEYDOWN
message in the derived class. If you want the parent window (the
dialog) to handle a notification, post a user defined message to the
parent window.

2. Handle the WM_KEYDOWN message in the dialog's PreTranslateMessage,
and check that the button control has the focus by using GetFocus.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Sun, 11 Sep 2005 20:43:15 GMT  
 Detecting keypress when the focus is on CButton
Dave,
thanks for attention.

Quote:

> 2 possible ways to go:

> 1. Try deriving a class from CButton and handling the WM_KEYDOWN
> message in the derived class. If you want the parent window (the
> dialog) to handle a notification, post a user defined message to the
> parent window.

Yes,  done. I thought it was automatic into the MFC but it did not ...
Thanks again.
--
Stefano Mora

(remove *)


Mon, 12 Sep 2005 09:35:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. catching a TAB-keypress on a CButton

2. Detecting A Keypress

3. Detecting keypress

4. HELP! Keypress detect

5. Detecting a keypress

6. How To Detect KeyPress.

7. HOW TO: detect a keypress

8. Detecting delete keypress in OnChar

9. Detect keypress in dialog-based

10. CButton that does not gain focus?

11. Q1 CButton without focus

12. CButton: focus and default

 

 
Powered by phpBB® Forum Software