新建单文档工程,在MainFrm.cpp中添加虚函数OnCreateClicent();
1、在虚函数中添加代码:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类
CRect rect;
GetClientRect(&rect);
m_wndSplitter.CreateStatic(this,1,2);//静态分割<span style="white-space:pre"> </span>
int cx = max(10,(rect.Width()-50))/2;
int cy = rect.Height();
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CSwitchFormView),CSize(cx,cy),pContext)//第一视图类View
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CLastFormView),CSize(cx,cy),pContext);//第二视图类View</span>
return TRUE;
//return CFrameWndEx::OnCreateClient(lpcs, pContext);
}</span>
2、在头文件MainFrm.h中添加:
// 特性
public:
CSplitterWnd m_wndSplitter;