15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Protected Constructors with Declare Dyncreate (Why?)

rwagner -- rwagner@genre.com
Monday, June 10, 1996

Why are protected constructors and destructors generated by the Class Wizard 
when I derive a class from CTreeview?

I'm finding this strange in a development environment where visual and 
non-visual objects intermix...

The environment is Visual C++ 4.1/MFC under Win '95.

Cheers,
Rob



Erik Funkenbusch -- chucks@isd.net
Monday, June 10, 1996

[Mini-digest: 2 responses]

> From: rwagner 
> Subject: Protected Constructors with Declare Dyncreate (Why?)
> Why are protected constructors and destructors generated by the Class
Wizard 
> when I derive a class from CTreeview?

Any view class is normally instantiated by the framework via  a document
template.

I say normally, because there are instances when you want to do it
yourself, but
for the vast majority of people this is rare.  Protected constructors are
just one
way that MFC uses to make sure people are not trying to do something they
really don't want to do.

If you've thought through your design and decide you need to instantiate
your
own view, then you can simply change the header to make the constructor
public.

-----From: Roger Onslow/Newcastle/Computer Systems Australia/AU 

>Why are protected constructors and destructors generated by the Class Wizard 
>when I derive a class from CTreeview?
>
>I'm finding this strange in a development environment where visual and 
>non-visual objects intermix...

View are created by CFrameWnd::CreateView() by calling
CView::CreateObject() (part of serialization support).  They
don't have must meaning outside the doc/frame/view
model.

It does not make sense to construct a view that is not "visual".
Surely a non-visual view would have no purpose!!
Perhaps you really want a CTreeCtrl rather than a
view??

Roger Onslow






| Вернуться в корень Архива |