Capturing Return in a UserControl 
Author Message
 Capturing Return in a UserControl

I'm building an editable Grid control in VB6 in
which I want to be able to intercept RETURN, TAB,
and ESCAPE keypresses in order to prevent them
from firing the default buttons/actions in the
form on which the grid will reside.

I've subclassed the constituent controls, but do
not appear to be recieving WM_KEYDOWN and
WM_KEYUP events for these keys (although I seem
to get them for all the others...) I've got
around the tab issue by trapping WM_KILLFOCUS,
but the escape and return keys still elude me if
there is a default and/or cancel button on the
parent form. What I find strange is that Spy++
shows that the WM_KEY* messages ARE posted when
the keys are hit, but my subclassing procedures
do not pick them up - maybe they can be seen by a
HookProc, but not a WndProc (or maybe I'm just
losing my marbles...)

The best that I can find in the MSDN is to handle
the WM_GETDLGCODE message, but that does not
appear to be posted by the controls in my
UserControl.

I know that I could put some code in the form to
remove the default and cancel properties of the
OK and Cancel buttons in the form when my grid
has the focus, but I'd rather write a general
case solution that doesn't require any extra code
in the parent (and besides - I want to do
something else with these keys). Does anyone have
any ideas ?

Pete Cozens

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 23 Feb 2003 16:32:28 GMT  
 Capturing Return in a UserControl
(Sorry if this is a repost - I've just set up my Deja account)

I'm building an editable Grid control in VB6 in which I want to be able
to intercept RETURN, TAB, and ESCAPE keypresses in order to prevent
them from firing the default buttons/actions in the form on which the
grid will reside.

I've subclassed the constituent controls, but do not appear to be
recieving WM_KEYDOWN and WM_KEYUP events for these keys (although I
seem to get them for all the others...). I've got around the tab issue
by trapping WM_KILLFOCUS, but the escape and return keys still elude me
if there is a default and cancel button on the parent form. What I find
strange is that Spy++ shows that the WM_KEY* messages ARE posted when
the keys are hit, but my subclassing procedures do not pick them up -
maybe they can be seen by a HookProc, but not a WndProc (or maybe I'm
just losing my marbles...)

The best that I can find in the MSDN is to handle the WM_GETDLGCODE
message, but that does not appear to be posted by the controls in my
UserControl.

I know that I could put some code in the form to remove the default and
cancel properties of the OK and Cancel buttons in the form when my grid
has the focus, but I'd rather write a general case solution that
doesn't require any extra code in the parent. Does anyone have any
ideas ?

Pete Cozens

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 23 Feb 2003 16:36:03 GMT  
 Capturing Return in a UserControl
You will find what you need here, allthough its not simple

http://vbaccelerator.com/codelib/scontrol/tabtrap.htm
Greg Boot

Quote:

> (Sorry if this is a repost - I've just set up my Deja account)

> I'm building an editable Grid control in VB6 in which I want to be able
> to intercept RETURN, TAB, and ESCAPE keypresses in order to prevent
> them from firing the default buttons/actions in the form on which the
> grid will reside.

> I've subclassed the constituent controls, but do not appear to be
> recieving WM_KEYDOWN and WM_KEYUP events for these keys (although I
> seem to get them for all the others...). I've got around the tab issue
> by trapping WM_KILLFOCUS, but the escape and return keys still elude me
> if there is a default and cancel button on the parent form. What I find
> strange is that Spy++ shows that the WM_KEY* messages ARE posted when
> the keys are hit, but my subclassing procedures do not pick them up -
> maybe they can be seen by a HookProc, but not a WndProc (or maybe I'm
> just losing my marbles...)

> The best that I can find in the MSDN is to handle the WM_GETDLGCODE
> message, but that does not appear to be posted by the controls in my
> UserControl.

> I know that I could put some code in the form to remove the default and
> cancel properties of the OK and Cancel buttons in the form when my grid
> has the focus, but I'd rather write a general case solution that
> doesn't require any extra code in the parent. Does anyone have any
> ideas ?

> Pete Cozens

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 24 Feb 2003 10:42:25 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Parent UserControl's Properties in a UserControl (placed on another UserControl)

2. Return value in a UserControl Active X

3. What does Usercontrol.parent return when hosted in IE4 and IE5

4. Acc97: Capturing return codes from DoCmd

5. Acc97: Capturing return code from DoMsg

6. Capturing return value of Stored Procedure...

7. Can't capture the rc returned from a store procedure using cursor

8. Capturing Stored proc. return value

9. Capturing Oracle return codes in Visual Basic

10. Capturing Return Value

11. Capture Return Value of a VB application (Most Urgent)

12. How to make the button in Usercontrol call Usercontrol's Click event

 

 
Powered by phpBB® Forum Software