Subclassing windows 
Author Message
 Subclassing windows

Hi,

I have a dialog resource with several controls. What I would like to do
is intercept in my dialog class the WM_KEYDOWN messages for each
control.

Is there any way to do this with subclassing? If so then how do you do
it!

Thanks,
Cameron.

P.S What is the effect of myControl.SubclassDlgItem( IDC_XX, this )? It
seems to me that this will send all control notification messages to the
control? Doesn't it do this anyway without the subclass?



Sat, 04 Nov 2000 03:00:00 GMT  
 Subclassing windows

Yes, you should use SubclassDlgItem().
1. Create a class derived from the control you use -
    for example - class CMyControl : public CEdit.
2. Map WM_KEYDOWN message to this class.
3. in CMyControl::OnKeyDown do whatever you want.
4. Now if you define myControl of type CMyControl, and call
myControl.SubclassDlgItem(..), you'll get what you want.

Naama

On Tue, 19 May 1998 15:22:13 -0700, Cameron Murray

Quote:

>Hi,

>I have a dialog resource with several controls. What I would like to do
>is intercept in my dialog class the WM_KEYDOWN messages for each
>control.

>Is there any way to do this with subclassing? If so then how do you do
>it!

>Thanks,
>Cameron.

>P.S What is the effect of myControl.SubclassDlgItem( IDC_XX, this )? It
>seems to me that this will send all control notification messages to the
>control? Doesn't it do this anyway without the subclass?

Naama Bamberger
Accent Software International



Sat, 04 Nov 2000 03:00:00 GMT  
 Subclassing windows

A good idea is to use an Hook (SetWindowsHookEx, with  WH_KEYBOARD as
parameter). If you want a sample, write me back.

Quote:

> Hi,

> I have a dialog resource with several controls. What I would like to do
> is intercept in my dialog class the WM_KEYDOWN messages for each
> control.

> Is there any way to do this with subclassing? If so then how do you do
> it!

> Thanks,
> Cameron.

> P.S What is the effect of myControl.SubclassDlgItem( IDC_XX, this )? It
> seems to me that this will send all control notification messages to the
> control? Doesn't it do this anyway without the subclass?



Sat, 04 Nov 2000 03:00:00 GMT  
 Subclassing windows

<<-;snip;->>>

P.S What is the effect of myControl.SubclassDlgItem( IDC_XX, this )? It

Quote:
>seems to me that this will send all control notification messages to the
>control? Doesn't it do this anyway without the subclass?

No, the default behaviour is to send the message to the parent (the Dialog).
You can make the control handle the message though, using message reflection
(it's round-about, but that's the way the MSFT guys designed it ;-O)

Murali Krishna Devarakonda



Sat, 04 Nov 2000 03:00:00 GMT  
 Subclassing windows



Quote:
> Hi,

> I have a dialog resource with several controls. What I would like to do
> is intercept in my dialog class the WM_KEYDOWN messages for each
> control.

> Is there any way to do this with subclassing? If so then how do you do
> it!

Yes, it is possible to do that with subclassing; but in my experience it is
much simpler to everride CDialog::PreTranslateMessage. This way you get a
look at every message and you don't have to subclass anything; you don't
have to rewrite your code after you add or remove some controls.




Sun, 05 Nov 2000 03:00:00 GMT  
 Subclassing windows

<snip>

Quote:
>Doesn't it do this anyway without the subclass?

Hi Cameron

I think you might find that Class Wizard is adding DDX_Control() calls for
any control member variables that you add to your dialog and this has a
similar effect, although I'm not quite sure how !

Jon

Lately it occurs to me what a long strange trip it's been ...



Sun, 05 Nov 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Subclassing window

2. Subclassing window

3. Subclassing Windows

4. Subclassing Windows class in MFC

5. Subclassing window

6. Subclassing Windows

7. Q: subclassing windows in other application

8. Subclassing window

9. Subclassing Window Question

10. Help:ACIVEX controls- subclassing Windows Control

11. Subclassing foreign window and changing memory in it

12. Subclassing a window in different process

 

 
Powered by phpBB® Forum Software