How to Create CCtrlView derived class based on CTreeCtrl derived class 
Author Message
 How to Create CCtrlView derived class based on CTreeCtrl derived class

Hi,
I have written a class that derives from CTreeCtrl that has a lot of
functionality that I would now like to use in a CTreeView. The problem is
that I have been unable to see how I can modify my derived CTreeView class
so that it is based on my derived CTreeCtrl class. The only options I seem
to have (from looking at the MFC source for CCtrlView and CTreeView) are:

1) Derive a new class from CCtrlView called for example CMyCtrlView. I could
put all of the functionality that I wanted in here and then derive new views
from it whenever I want.

2) Derive a class from CTreeView and add all of my functionality there,
mapping messages that are reflected from the tree control to the view.

The problem with both of these approaches are that they don't allow me to
reuse all of the code that I have created for my derived CTreeCtrl class.
Does anyone have a different approach that does allow me to reuse this code?
Is there something I am missing here?

Thanks in advance,
Jon Walker
Senior Software Engineer
Miramar Systems, Inc.



Tue, 06 Feb 2001 03:00:00 GMT  
 How to Create CCtrlView derived class based on CTreeCtrl derived class
Hi,

Make your class that derives from CTreeCtrl instead derive from a template
parameter. Then, for a CTreeCtrl derived class, derive from your templatized
class with CTreeCtrl as the base class parameter. For a CTreeView derived
class, derive a class from your templatized class with a CTreeView base
class.

This could be done with little difficulty and will allow you to not have to
duplicate any of your core code, and still have both a CTreeCtrl
implementation and a CTreeView implementation.

Good Luck!

Steve
Stingray Software
http://www.stingray.com

Quote:

>Hi,
>I have written a class that derives from CTreeCtrl that has a lot of
>functionality that I would now like to use in a CTreeView. The problem is
>that I have been unable to see how I can modify my derived CTreeView class
>so that it is based on my derived CTreeCtrl class. The only options I seem
>to have (from looking at the MFC source for CCtrlView and CTreeView) are:

>1) Derive a new class from CCtrlView called for example CMyCtrlView. I
could
>put all of the functionality that I wanted in here and then derive new
views
>from it whenever I want.

>2) Derive a class from CTreeView and add all of my functionality there,
>mapping messages that are reflected from the tree control to the view.

>The problem with both of these approaches are that they don't allow me to
>reuse all of the code that I have created for my derived CTreeCtrl class.
>Does anyone have a different approach that does allow me to reuse this
code?
>Is there something I am missing here?

>Thanks in advance,
>Jon Walker
>Senior Software Engineer
>Miramar Systems, Inc.



Tue, 06 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to Create CCtrlView derived class based on CTreeCtrl derived class

2. Derived CCtrlView with derived CTreeCtrl...

3. creating an instance of a derived class from a base class

4. New Class derived from Class which derived from CWindowImpl

5. Activating the class wizard on a derived-derived Cwnd class

6. Creating derived dialogue from CDialog-derived class

7. Flicker-free drawing with CCtrlView-derived class, CMemDC, and CDC::GetClipBox()

8. Flicker-free drawing with CCtrlView-derived class, CMemDC, and CDC::GetClipBox()

9. How to Stop Derived Class from overriding base class method

10. How to prevent derived classes from changing a base class function

11. address of base class and derived class different

12. Deriving from CControlBar - no base class in New Class dialog

 

 
Powered by phpBB® Forum Software