在MFC 的视窗设计中,我一般喜欢选单文档,但缺省是一个视图。我需要2个或多个视窗。怎么设计呢?
需要修改2个类就可以了, CMainFrame,CxxxApp:
在CMainFrame中,
添加分割 CSplitterWnd
CSplitterWnd m_spliter1; //原版的CSplitterWnd
然后重载CMainFrame类的OnCreateClient()函数,在该函数中添加如下代码:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect rect;
GetClientRect( &rect );
CSize size = rect.Size();
size.cx =size.cx-300; // Initial column size
//size.cy /= 2; // Initial row size
// 1 - Create first static splitter
if( !m_wndSplitter1.CreateStatic( this, 1, 2 ) ) // 1 row, 2 cols
{
TRACE0( "Failed to create first static splitter\n" );
return FALSE;
}
// 2 - Create left column view
if( !m_wndSplitter1.CreateView( 0, 0, // row 0, col 0
RUNTIME_CLASS( Crtc5View2 ),
//RUNTIME_CLASS( CLaserXyzView ),
size, pContext ) )
{
TRACE0( "Failed to create left view\n" );
return FALSE;
&nb