www.pudn.com > 单文档多视图.rar > MainFrm.cpp


// MainFrm.cpp : implementation of the CMainFrame class 
// 
 
#include "stdafx.h" 
#include "SdiMulti.h" 
 
#include "MainFrm.h" 
 
#include "SdiMDoc.h" 
 
#include "View1.h" 
#include "View2.h" 
#include "View3.h" 
#include "View4.h" 
#include "View5.h" 
#include "View6.h" 
#include "View7.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame 
 
IMPLEMENT_DYNCREATE(CMainFrame, CSDIFrameWnd) 
 
BEGIN_MESSAGE_MAP(CMainFrame, CSDIFrameWnd) 
	//{{AFX_MSG_MAP(CMainFrame) 
	ON_WM_CREATE() 
	ON_COMMAND(ID_VIEW_EDIT_VIEW, OnViewEditView) 
	ON_COMMAND(ID_VIEW_SPLITTER1_TREE_VIEW, OnViewSplitter1TreeView) 
	ON_COMMAND(ID_VIEW_SPLITTER1_LIST_VIEW, OnViewSplitter1ListView) 
	ON_COMMAND(ID_VIEW_SPLITTER2_VIEW_VIEW, OnViewSplitter2ViewView) 
	ON_COMMAND(ID_VIEW_SPLITTER2_SCROLL_VIEW, OnViewSplitter2ScrollView) 
	ON_COMMAND(ID_VIEW_RICH_EDIT_VIEW, OnViewRichEditView) 
	ON_COMMAND(ID_VIEW_FORM_VIEW, OnViewFormView) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_EDIT_VIEW, OnUpdateViewEditView) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_FORM_VIEW, OnUpdateViewFormView) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_RICH_EDIT_VIEW, OnUpdateViewRichEditView) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_SPLITTER1_LIST_VIEW, OnUpdateViewSplitter1ListView) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_SPLITTER1_TREE_VIEW, OnUpdateViewSplitter1TreeView) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_SPLITTER2_SCROLL_VIEW, OnUpdateViewSplitter2ScrollView) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_SPLITTER2_VIEW_VIEW, OnUpdateViewSplitter2ViewView) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
static UINT indicators[] = 
{ 
	ID_SEPARATOR,           // status line indicator 
	ID_INDICATOR_CAPS, 
	ID_INDICATOR_NUM, 
	ID_INDICATOR_SCRL, 
}; 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame construction/destruction 
 
CMainFrame::CMainFrame() 
{ 
	// TODO: add member initialization code here 
	 
} 
 
CMainFrame::~CMainFrame() 
{ 
} 
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	if (CSDIFrameWnd::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	if (!m_wndToolBar.Create(this) || 
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) 
	{ 
		TRACE0("Failed to create toolbar\n"); 
		return -1;      // fail to create 
	} 
 
	if (!m_wndStatusBar.Create(this) || 
		!m_wndStatusBar.SetIndicators(indicators, 
		  sizeof(indicators)/sizeof(UINT))) 
	{ 
		TRACE0("Failed to create status bar\n"); 
		return -1;      // fail to create 
	} 
 
	// TODO: Remove this if you don't want tool tips or a resizeable toolbar 
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | 
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); 
 
	// TODO: Delete these three lines if you don't want the toolbar to 
	//  be dockable 
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 
	EnableDocking(CBRS_ALIGN_ANY); 
	DockControlBar(&m_wndToolBar); 
 
	return 0; 
} 
 
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CSDIFrameWnd::PreCreateWindow(cs); 
} 
 
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
	return CSDIFrameWnd::OnCreateClient(lpcs, pContext); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame diagnostics 
 
#ifdef _DEBUG 
void CMainFrame::AssertValid() const 
{ 
	CSDIFrameWnd::AssertValid(); 
} 
 
void CMainFrame::Dump(CDumpContext& dc) const 
{ 
	CSDIFrameWnd::Dump(dc); 
} 
 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame message handlers 
 
void CMainFrame::OnViewEditView()  
{ 
	ActivateView(RUNTIME_CLASS(C1View)); 
} 
 
void CMainFrame::OnUpdateViewEditView(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(IsViewActive(RUNTIME_CLASS(C1View))); 
} 
 
void CMainFrame::OnViewSplitter1TreeView()  
{ 
	ActivateView(RUNTIME_CLASS(C2View)); 
} 
 
void CMainFrame::OnUpdateViewSplitter1TreeView(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(IsViewActive(RUNTIME_CLASS(C2View))); 
} 
 
void CMainFrame::OnViewSplitter1ListView()  
{ 
	ActivateView(RUNTIME_CLASS(C3View)); 
} 
 
void CMainFrame::OnUpdateViewSplitter1ListView(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(IsViewActive(RUNTIME_CLASS(C3View))); 
} 
 
void CMainFrame::OnViewSplitter2ViewView()  
{ 
	ActivateView(RUNTIME_CLASS(C4View)); 
} 
 
void CMainFrame::OnUpdateViewSplitter2ViewView(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(IsViewActive(RUNTIME_CLASS(C4View))); 
} 
 
void CMainFrame::OnViewSplitter2ScrollView()  
{ 
	ActivateView(RUNTIME_CLASS(C5View)); 
} 
 
void CMainFrame::OnUpdateViewSplitter2ScrollView(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(IsViewActive(RUNTIME_CLASS(C5View))); 
} 
 
void CMainFrame::OnViewRichEditView()  
{ 
	ActivateView(RUNTIME_CLASS(C6View)); 
} 
 
void CMainFrame::OnUpdateViewRichEditView(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(IsViewActive(RUNTIME_CLASS(C6View))); 
} 
 
void CMainFrame::OnViewFormView()  
{ 
	ActivateView(RUNTIME_CLASS(C7View)); 
} 
 
void CMainFrame::OnUpdateViewFormView(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(IsViewActive(RUNTIME_CLASS(C7View))); 
}