Re: CSingleDocTemplate

Tech-Archive recommends: Fix windows errors by optimizing your registry



RUNTIME_CLASS does not allocate the class in memory; it is a macro that accesses the embedded
CRuntimeClass object that describes the class. It permits things like IsKindOf tests and
CreateObject to dynamically create the object as needed.

Yes, the CLeftView window will be a child of the splitter, which is a child of the main frame. The
purpose of the doc template object is to associate a document class, a frame window class, and a
view class together for the purposes of dynamically creating them in response to file open or file
new commands. Adding the class to the doc template doesn't really have anything to do with
parent-child relationship of windows, except that the view will always be a descendant of the frame
window.

"RG" <RG@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:76A32BE8-5527-404D-93FC-5DCD3F44C4F3@xxxxxxxxxxxxxxxx
>I am a bit confused about MFC framework and was wondering if somebody could
> help.
>
> I was using mfc wizard in vsnet 2003 to create an explorer type application.
>
> Looking at the application class, I found the following statement:
>
> pDocTemplate = new CSingleDocTemplate(
> IDR_MAINFRAME,
> RUNTIME_CLASS(Ct1Doc),
> RUNTIME_CLASS(CMainFrame), // main SDI frame window
> RUNTIME_CLASS(CLeftView));
>
>
> In the MainFrame class, I found the following statement:
>
>
> if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100,
> 100), pContext) ||
> !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(Ct1View), CSize(100, 100),
> pContext))
>
>
> 1. If RUNTIME_CLASS dynamically allocates this class in memory, why is
> RUNTIME_CLASS(CLeftView) performed twice?
>
> 2. Why is the CLeftView added to the doc template? Isn't it a child of
> MainFrame?
>
> Thanks in advance
>
>


.



Relevant Pages