Subclassing MFC 
Author Message
 Subclassing MFC

Hi,

I want to add a Windows control, say CEdit, to my dialog form.  That's the
easy part.  I want that CEdit control on the dialog form to reference my
subclassed CEdit, MyCEdit.  How do you make the connection that the control
that you placed on the form references your subclassed control?

Thanks,

Scott



Sun, 01 Dec 2002 03:00:00 GMT  
 Subclassing MFC
Assuming you have created a new class based on CEdit, go to the Class Wizard
and add a control variable for your CEdit control.  Select MyCEdit as the
variable type.

Mike Ober.


Quote:
> Hi,

> I want to add a Windows control, say CEdit, to my dialog form.  That's the
> easy part.  I want that CEdit control on the dialog form to reference my
> subclassed CEdit, MyCEdit.  How do you make the connection that the
control
> that you placed on the form references your subclassed control?

> Thanks,

> Scott



Sun, 01 Dec 2002 03:00:00 GMT  
 Subclassing MFC

Quote:
>I want to add a Windows control, say CEdit, to my dialog form.  That's the
>easy part.  I want that CEdit control on the dialog form to reference my
>subclassed CEdit, MyCEdit.  How do you make the connection that the control
>that you placed on the form references your subclassed control?

Scott,

If you derive a class from CEdit using the Class View, New Class
facility - when you come to add a member variable to an edit control
on a dialog Class Wizard allows you to choose between a normal CEdit
control or your own derived CMyEdit class.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Sun, 01 Dec 2002 03:00:00 GMT  
 Subclassing MFC
Scott:

Even if your class does not show up in ClassWizard you can add a CEdit
control variable and simply change the designation in the dilaog header
from CEdit to CMyEdit (and #include the MyEdit header). The DDX_Control
mechanism which MFC uses to attach a CEdit control variable is in no way
different from the one it uses to attach your derived control.
Equivalently you can do it yourself in InitDialog using
SubclassDlgItem().

HTH,

David Wilkinson

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

Quote:

> >I want to add a Windows control, say CEdit, to my dialog form.  That's the
> >easy part.  I want that CEdit control on the dialog form to reference my
> >subclassed CEdit, MyCEdit.  How do you make the connection that the control
> >that you placed on the form references your subclassed control?

> Scott,

> If you derive a class from CEdit using the Class View, New Class
> facility - when you come to add a member variable to an edit control
> on a dialog Class Wizard allows you to choose between a normal CEdit
> control or your own derived CMyEdit class.

> Dave
> --
> MVP VC++ FAQ: http://www.mvps.org/vcfaq
> My address is altered to discourage junk mail.
> Please post responses to the newsgroup thread,
> there's no need for follow-up email copies.



Sun, 01 Dec 2002 03:00:00 GMT  
 Subclassing MFC
To all,

Thanks for the insight.  It now works as I wanted it to.

The time I burned looking through the documentation, I could have spent
shootin' the breeze, Dilbert style.

I appreciate the time from all.

Scott


Quote:
> Hi,

> I want to add a Windows control, say CEdit, to my dialog form.  That's the
> easy part.  I want that CEdit control on the dialog form to reference my
> subclassed CEdit, MyCEdit.  How do you make the connection that the
control
> that you placed on the form references your subclassed control?

> Thanks,

> Scott



Sun, 01 Dec 2002 03:00:00 GMT  
 Subclassing MFC
I have done a lot of this lately..  And what I miss in MFC is what Delphi
does naturally..  If you derive a class based on a listbox or anything else,
you can publish it on the component pallete and then use that component in
ANY project later on just like dropping the component from your pallette on
a dlg in Visual studio.  I wish the visual studio designers would somehow
work this into play so that when I am forced to write in VC++ I don't spend
a bunch of time figuring out where to put the SubClassDlgItem() and how to
get that to work..  If you have already added the functionality, why should
you not automatically be able to use that component in all of you future
products..

Paul


Quote:
> To all,

> Thanks for the insight.  It now works as I wanted it to.

> The time I burned looking through the documentation, I could have spent
> shootin' the breeze, Dilbert style.

> I appreciate the time from all.

> Scott



> > Hi,

> > I want to add a Windows control, say CEdit, to my dialog form.  That's
the
> > easy part.  I want that CEdit control on the dialog form to reference my
> > subclassed CEdit, MyCEdit.  How do you make the connection that the
> control
> > that you placed on the form references your subclassed control?

> > Thanks,

> > Scott



Tue, 03 Dec 2002 03:00:00 GMT  
 Subclassing MFC
Well, there is a component gallery you can add things to, and if
you're calling SubclassDlgItem you're not using MFC optimally. I've
not called SubclassDlgItem except in a couple really weird cases.
                        joe



Quote:
>I have done a lot of this lately..  And what I miss in MFC is what Delphi
>does naturally..  If you derive a class based on a listbox or anything else,
>you can publish it on the component pallete and then use that component in
>ANY project later on just like dropping the component from your pallette on
>a dlg in Visual studio.  I wish the visual studio designers would somehow
>work this into play so that when I am forced to write in VC++ I don't spend
>a bunch of time figuring out where to put the SubClassDlgItem() and how to
>get that to work..  If you have already added the functionality, why should
>you not automatically be able to use that component in all of you future
>products..

>Paul



>> To all,

>> Thanks for the insight.  It now works as I wanted it to.

>> The time I burned looking through the documentation, I could have spent
>> shootin' the breeze, Dilbert style.

>> I appreciate the time from all.

>> Scott



>> > Hi,

>> > I want to add a Windows control, say CEdit, to my dialog form.  That's
>the
>> > easy part.  I want that CEdit control on the dialog form to reference my
>> > subclassed CEdit, MyCEdit.  How do you make the connection that the
>> control
>> > that you placed on the form references your subclassed control?

>> > Thanks,

>> > Scott

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Thu, 12 Dec 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Subclassing MFC windows

2. Subclassing MFC based windows. How do you do it?

3. Subclassing in MFC

4. Subclassing Windows class in MFC

5. newbie: subclassing richedit in an ActiveX MFC ctl

6. MFC Subclassing

7. subclassing a MFC subclassed window

8. Subclassing Activex controls from commctrl (treectrl) in MFC

9. Subclassing (superclassing?) MFC control from commctrl (treectrl)

10. MFC OCX Subclassing Problem

11. MFC Clist control subclassing

12. US-TX-DFW DALLAS DEVELOPERS - Visual C++ / MFC / JUST ONE YEAR OF MFC ----MFC---MFC

 

 
Powered by phpBB® Forum Software