m_pMainWnd 实例化的地方

Where m_pMainWnd is instantiated

我刚刚开始使用 Microsoft Foundation 类,在我使用新项目向导的 hello world 应用程序中,我看到对 m_pMainWnd->ShowWindow(SW_SHOW) 的引用和 InitInstance() 方法中的 m_pMainWnd->UpdateWindow()。我知道 m_pMainWnd 是指向主应用程序 window 的指针。我的问题是我只在 afxwin.h 中看到它的声明,但在任何地方都看不到它的实例化。有什么我想念的吗,如果我错了,请纠正我。我是一个新手程序员。

主框架 window 在您的应用程序(CWinApp 派生)的 InitInstance() 方法中实例化 class 就像这样:

CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CNetworkManagerDoc),
    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    RUNTIME_CLASS(CNetworkManagerView));
if (!pDocTemplate)
    return FALSE;
AddDocTemplate(pDocTemplate);