www.pudn.com > PL0_compiler.rar > PL0View.cpp


// PL0View.cpp : implementation of the CPL0View class 
// 
 
#include "stdafx.h" 
#include "PL0.h" 
 
#include "PL0Doc.h" 
#include "CntrItem.h" 
#include "PL0View.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CPL0View 
 
IMPLEMENT_DYNCREATE(CPL0View, CRichEditView) 
 
BEGIN_MESSAGE_MAP(CPL0View, CRichEditView) 
	//{{AFX_MSG_MAP(CPL0View) 
	ON_WM_DESTROY() 
	ON_WM_CREATE() 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRichEditView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CPL0View construction/destruction 
 
CPL0View::CPL0View() 
{ 
	// TODO: add construction code here 
 
} 
 
CPL0View::~CPL0View() 
{ 
} 
 
BOOL CPL0View::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CRichEditView::PreCreateWindow(cs); 
} 
 
void CPL0View::OnInitialUpdate() 
{ 
	CRichEditView::OnInitialUpdate(); 
 
 
	// Set the printing margins (720 twips = 1/2 inch). 
	SetMargins(CRect(720, 720, 720, 720)); 
	GetRichEditCtrl().ReplaceSel("此处输入源代码...\n"); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CPL0View printing 
 
BOOL CPL0View::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
 
void CPL0View::OnDestroy() 
{ 
	// Deactivate the item on destruction; this is important 
	// when a splitter view is being used. 
   CRichEditView::OnDestroy(); 
   COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); 
   if (pActiveItem != NULL && pActiveItem->GetActiveView() == this) 
   { 
      pActiveItem->Deactivate(); 
      ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL); 
   } 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CPL0View diagnostics 
 
#ifdef _DEBUG 
void CPL0View::AssertValid() const 
{ 
	CRichEditView::AssertValid(); 
} 
 
void CPL0View::Dump(CDumpContext& dc) const 
{ 
	CRichEditView::Dump(dc); 
} 
 
CPL0Doc* CPL0View::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPL0Doc))); 
	return (CPL0Doc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CPL0View message handlers 
 
void CPL0View::Insert(const char *szText) 
{ 
	ASSERT(this->m_hWnd); 
	SendMessage(EM_REPLACESEL,(WPARAM) 0,(LPARAM) szText); 
} 
 
void CPL0View::Insert(CString &strText) 
{ 
	Insert((LPCSTR)strText); 
} 
 
void CPL0View::Insert(char ch) 
{ 
	char szText[2]; 
	szText[0]=ch; 
	szText[1]='\0'; 
	Insert(szText); 
} 
 
 
int CPL0View::OnCreate(LPCREATESTRUCT lpCreateStruct)  
{ 
	if (CRichEditView::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	// TODO: Add your specialized creation code here 
	CPL0Doc* pDoc = GetDocument(); 
	pDoc->m_wndCPL0View = this; 
	return 0; 
}