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


// FirstView.cpp : implementation of the C1View class 
// 
 
#include "stdafx.h" 
#include "SdiMulti.h" 
 
#include "SdiMDoc.h" 
#include "View1.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// C1View 
 
IMPLEMENT_DYNCREATE(C1View, CEditView) 
 
BEGIN_MESSAGE_MAP(C1View, CEditView) 
	//{{AFX_MSG_MAP(C1View) 
	ON_CONTROL_REFLECT(EN_CHANGE, OnChange) 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// C1View construction/destruction 
 
C1View::C1View() 
{ 
	// TODO: add construction code here 
 
} 
 
C1View::~C1View() 
{ 
} 
 
BOOL C1View::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	BOOL bPreCreated = CEditView::PreCreateWindow(cs); 
	cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL);	// Enable word-wrapping 
 
	return bPreCreated; 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// C1View drawing 
 
void C1View::OnDraw(CDC* pDC) 
{ 
	CSdiMultiDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
 
	// TODO: add draw code for native data here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// C1View printing 
 
BOOL C1View::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default CEditView preparation 
	return CEditView::OnPreparePrinting(pInfo); 
} 
 
void C1View::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) 
{ 
	// Default CEditView begin printing. 
	CEditView::OnBeginPrinting(pDC, pInfo); 
} 
 
void C1View::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo) 
{ 
	// Default CEditView end printing 
	CEditView::OnEndPrinting(pDC, pInfo); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// C1View diagnostics 
 
#ifdef _DEBUG 
void C1View::AssertValid() const 
{ 
	CEditView::AssertValid(); 
} 
 
void C1View::Dump(CDumpContext& dc) const 
{ 
	CEditView::Dump(dc); 
} 
 
CSdiMultiDoc* C1View::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSdiMultiDoc))); 
	return (CSdiMultiDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// C1View operations 
 
void C1View::WriteText(LPCSTR lpszString) 
{ 
  CEdit& Edit = GetEditCtrl(); 
  Edit.SetSel(-1, -1, NULL); 
  Edit.ReplaceSel(lpszString); 
} 
 
void C1View::ClearView() 
{ 
  GetEditCtrl().SetWindowText(NULL); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// C1View message handlers 
 
void C1View::OnInitialUpdate()  
{ 
	ClearView(); 
	GetEditCtrl().SetReadOnly(TRUE); 
	CEditView::OnInitialUpdate(); 
 
	WriteText("This is the CEditView\r\n\r\n"); 
 
	WriteText("SDIMULTI is a sample to create Multi-Views Multi-splitters Single document interface.\r\n\r\n"); 
 
	WriteText("To create an SDIMULTI application, do this.\r\n"); 
	WriteText("- Create an SDI Application.\r\n"); 
	WriteText("- Add SdiApp.* and SdiFrame.* to your project.\r\n"); 
	WriteText("- Derive your CWinApp aplication from CSDIWinApp.\r\n"); 
	WriteText("- Derive your MainFrame from CSDIFrameWnd.\r\n"); 
	WriteText("- Use CSDIDocTemplate as CSingleDocTemplate.\r\n\r\n"); 
 
	WriteText("- In the InitInstance(), add DocTemplates whith splitter ID, row and col.\r\n"); 
	WriteText("- In your MainFrame, add command messages to switch between views.\r\n"); 
 
	WriteText("That's all.\r\n"); 
} 
 
void C1View::OnChange()  
{ 
	// only to not set the modified flag of the document 
}