单文档中的CMainFrame是什么时分创建的

单文档中的CMainFrame是什么时候创建的
InitInstance中并没有看到类似m_pMainwnd= new CMainFrame,而是直接出现了这样的代码
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMy54354Doc),
RUNTIME_CLASS(CMainFrame),       // main SDI frame window
RUNTIME_CLASS(CMy54354View));

RUNTIME_CLASS(CMainFrame)是一个宏,代入就是
#define RUNTIME_CLASS(CMainFrame) ((CRuntimeClass*)(&CMainFrame::classCMainFrame))
但是我并没有看到创建CMainFrame,请教。
------解决方案--------------------
CMainFrame类对象创建流程如下:
1>BOOL CSIDApp::InitInstance()中调用ProcessShellCommand


2>BOOL CWinApp::ProcessShellCommand(CCommandLineInfo& rCmdInfo)代码:
BOOL CWinApp::ProcessShellCommand(CCommandLineInfo& rCmdInfo)
{
BOOL bResult = TRUE;
switch (rCmdInfo.m_nShellCommand)
{
case CCommandLineInfo::FileNew:
if (!AfxGetApp()->OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL))//此处调用CWinApp::OnFileNew,但是CWinApp中没有改写OnFileNew所以调用的是基类CCmdTarget::OnFileNew,创建CMainFrame对象;你可以跟踪以下在此之前m_pMainWnd=NULL;
OnFileNew();
if (m_pMainWnd == NULL)
bResult = FALSE;
break;

------解决方案--------------------
在MainFrm.cpp中加上虚函数
BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle , const RECT& rect , CWnd* pParentWnd , LPCTSTR lpszMenuName , DWORD dwExStyle , CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类

return CFrameWndEx::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, lpszMenuName, dwExStyle, pContext);
}

设断点,运行,查看堆栈,创建过程如下:
CMainFrame::Create() 行 412
CFrameWnd::LoadFrame()  行 745 + 0x35 字节
CFrameWndEx::LoadFrame()  行 378 + 0x18 字节
CMainFrame::LoadFrame()  行 376 + 0x18 字节
CDocTemplate::CreateNewFrame()  行 294 + 0x22 字节
CSingleDocTemplate::OpenDocumentFile()  行 133 + 0x13 字节
CSingleDocTemplate::OpenDocumentFile()  行 84
CDocManager::OnFileNew()  行 926
CWinApp::OnFileNew()  行 22
_AfxDispatchCmdMsg()  行 82
CCmdTarget::OnCmdMsg()  行 381 + 0x27 字节
CWinApp::ProcessShellCommand()  行 35 + 0x20 字节
CaApp::InitInstance()  行 132 + 0xf 字节

有点晕~~