Subclassing all dialogs edits 
Author Message
 Subclassing all dialogs edits

Hi

I have a dialog box with many edits in.  I also have a class descended from
CEdit which does not allow the control to get the focus.  I want all the
edits in the dialog to be subclassed to this class (is that the right way to
say it?).  Do I have to have an instance of the class for each edit or can I
some how globally subclass all the edits?

I hope I have explained what I want.

Regards

Malc



Tue, 11 Dec 2001 03:00:00 GMT  
 Subclassing all dialogs edits
Malcolm:

I think in Win32 it is possible to subclass a whole class, as opposed to a
particular window, but in MFC I think you need to subclass each control.

But it is very easy:

1. Use CW to assign a CEdit control variable to each of the edit controls on the
template.

2. Edit the .h file of your dialog to change all the CEdit declarations to
CMyEdit declarations. The DDX_Control statements which MFC inserts will now
attach your edit class to the controls.

HTH,

David Wilkinson

==============

Quote:

> Hi

> I have a dialog box with many edits in.  I also have a class descended from
> CEdit which does not allow the control to get the focus.  I want all the
> edits in the dialog to be subclassed to this class (is that the right way to
> say it?).  Do I have to have an instance of the class for each edit or can I
> some how globally subclass all the edits?

> I hope I have explained what I want.

> Regards

> Malc



Tue, 11 Dec 2001 03:00:00 GMT  
 Subclassing all dialogs edits

Quote:
>I have a dialog box with many edits in.  I also have a class descended from
>CEdit which does not allow the control to get the focus.  I want all the
>edits in the dialog to be subclassed to this class (is that the right way to
>say it?).  Do I have to have an instance of the class for each edit or can I
>some how globally subclass all the edits?

Malc,

2 possibilities spring to mind:

Handle it for all the edit controls in the dialog's
PreTranslateMessage, or, attach a member variable of your sub-classed
edit control to each edit control in the dialog.

Dave
----
Address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow up email copies.
http://www.bj.co.uk



Tue, 11 Dec 2001 03:00:00 GMT  
 Subclassing all dialogs edits
Aha! I done something like this in my current job.

What you need to do is call Win32's ::EnumWindows in your OnInitDialog() (or
equivalent).

Add a global function that's a friend to your dialog class. For each HWND
passed back in the EnumWindows callback, create a new instance of your CEdit
derived class and CEdit::Attach it to the HWND.

Much more reliable and far more useful! You don't need to use ClassWizard!

Scott Tunstall

Quote:

>Hi

>I have a dialog box with many edits in.  I also have a class descended from
>CEdit which does not allow the control to get the focus.  I want all the
>edits in the dialog to be subclassed to this class (is that the right way
to
>say it?).  Do I have to have an instance of the class for each edit or can
I
>some how globally subclass all the edits?

>I hope I have explained what I want.

>Regards

>Malc



Thu, 13 Dec 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Subclassing an edit control to do custom word wrapping

2. Subclassing edit-control of CComboBox

3. Selchange after subclassing List- and edit part ofderived CComboBox

4. Subclassing the edit control in CEditView

5. Subclassing Edit control

6. Trouble subclassing the edit control of a CComboBox

7. (Q) Subclassing CComboBox edit control

8. SubClassing Edit Control in CEditView

9. SubClassing a CEdit Control for Masked Edit.

10. Help ! Subclassing edit control

11. Help ! Subclassing edit control

12. Replace Edit with Rich Edit on Dialog?

 

 
Powered by phpBB® Forum Software