我新学MFC用的书是(Programming Windows with MFC)在看到单文本部分时有个示例(此书11章),是建立一个SDI的程序,将CDocument与CSplitter连接到一起,我看的源码部分在CWinApp类中,pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CWandererDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CDriveView));//CDriveView为SplitterWnd左侧的CView,
在MainFirm中是有一个 CSplitterWnd m_wndSplitter;然后CMainFrame::OnCreateClient中建立了左右2个CView,请问,右侧的View是怎么与CDocument建立起连接的呢?希望看过此书的或者写过类似代码的前辈给点帮助
IDR_MAINFRAME,
RUNTIME_CLASS(CWandererDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CDriveView));//CDriveView为SplitterWnd左侧的CView,
在MainFirm中是有一个 CSplitterWnd m_wndSplitter;然后CMainFrame::OnCreateClient中建立了左右2个CView,请问,右侧的View是怎么与CDocument建立起连接的呢?希望看过此书的或者写过类似代码的前辈给点帮助
{
// TODO: Add your specialized code here and/or call the base class
// create a splitter with 1 row, 2 columns
CRect rect;
long width, height; ShowWindow(SW_SHOWMAXIMIZED);
GetClientRect(&rect);
width = rect.right-rect.left;
height = rect.bottom-rect.top;
if (!m_wndSplitter.CreateStatic(this, 1, 2,WS_CHILD | WS_VISIBLE))
{
TRACE("Failed to CreateStaticSplitter\n");
return FALSE;
}
// First splitter pane
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CMyView), CSize(width-160,height), pContext))
{
TRACE("Failed to create command view pane\n");
return FALSE;
} if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CFormCommandView), CSize(160,height), pContext))
{
TRACE("Failed to create command view pane\n");
return FALSE;
}
// Second splitter pane
// return CMDIChildWnd::OnCreateClient(lpcs, pContext);
return TRUE;
}
你把RUNTIME_CLASS(CDriveView)改成NULL试试
程序没什么变化