⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezwpview.cpp

📁 讲mfc的书
💻 CPP
字号:
// ezwpView.cpp : implementation of the CEzwpView class
//

#include "stdafx.h"
#include "ezwp.h"

#include "ezwpDoc.h"
#include "CntrItem.h"
#include "ezwpView.h"

#include "CharPage.h"
#include "LinePage.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEzwpView

IMPLEMENT_DYNCREATE(CEzwpView, CRichEditView)

BEGIN_MESSAGE_MAP(CEzwpView, CRichEditView)
	//{{AFX_MSG_MAP(CEzwpView)
	ON_COMMAND(ID_CANCEL_EDIT_SRVR, OnCancelEditSrvr)
	ON_COMMAND(ID_CHARACTER_BOLD, OnCharacterBold)
	ON_UPDATE_COMMAND_UI(ID_CHARACTER_BOLD, OnUpdateCharacterBold)
	ON_COMMAND(ID_PARAGRAPH_CENTER, OnParagraphCenter)
	ON_UPDATE_COMMAND_UI(ID_PARAGRAPH_CENTER, OnUpdateParagraphCenter)
	ON_COMMAND(ID_CHARACTER_ITALIC, OnCharacterItalic)
	ON_UPDATE_COMMAND_UI(ID_CHARACTER_ITALIC, OnUpdateCharacterItalic)
	ON_COMMAND(ID_PARAGRAPH_LEFT, OnParagraphLeft)
	ON_UPDATE_COMMAND_UI(ID_PARAGRAPH_LEFT, OnUpdateParagraphLeft)
	ON_COMMAND(ID_PARAGRAPH_RIGHT, OnParagraphRight)
	ON_UPDATE_COMMAND_UI(ID_PARAGRAPH_RIGHT, OnUpdateParagraphRight)
	ON_COMMAND(ID_CHARACTER_FONT, OnCharacterFont)
	ON_COMMAND(IDM_Statistics, OnStatistics)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CEzwpView construction/destruction

CEzwpView::CEzwpView()
{
	// TODO: add construction code here

}

CEzwpView::~CEzwpView()
{
}

BOOL CEzwpView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CRichEditView::PreCreateWindow(cs);
}

void CEzwpView::OnInitialUpdate()
{
	CRichEditView::OnInitialUpdate();
	CHARFORMAT cf;
	memset(&cf,0,sizeof(cf));
	cf.cbSize=sizeof(cf);
	cf.dwMask=CFM_FACE|CFM_SIZE|CFM_BOLD|CFM_ITALIC;
	cf.yHeight=400;  // 20 points
	cf.bCharSet=DEFAULT_CHARSET;
	cf.bPitchAndFamily=DEFAULT_PITCH|FF_DONTCARE;
	strcpy(cf.szFaceName,"Times New Roman");
	SetCharFormat(cf);

}

/////////////////////////////////////////////////////////////////////////////
// CEzwpView printing

BOOL CEzwpView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}


/////////////////////////////////////////////////////////////////////////////
// OLE Server support

// The following command handler provides the standard keyboard
//  user interface to cancel an in-place editing session.  Here,
//  the server (not the container) causes the deactivation.
void CEzwpView::OnCancelEditSrvr()
{
	GetDocument()->OnDeactivateUI(FALSE);
}

/////////////////////////////////////////////////////////////////////////////
// CEzwpView diagnostics

#ifdef _DEBUG
void CEzwpView::AssertValid() const
{
	CRichEditView::AssertValid();
}

void CEzwpView::Dump(CDumpContext& dc) const
{
	CRichEditView::Dump(dc);
}

CEzwpDoc* CEzwpView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEzwpDoc)));
	return (CEzwpDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CEzwpView message handlers

void CEzwpView::OnCharacterBold() 
{
	OnCharEffect(CFM_BOLD,CFE_BOLD);
	
}

void CEzwpView::OnUpdateCharacterBold(CCmdUI* pCmdUI) 
{
	OnUpdateCharEffect(pCmdUI,CFM_BOLD,CFE_BOLD);
	
}

void CEzwpView::OnParagraphCenter() 
{
	OnParaAlign(PFA_CENTER);
	
}

void CEzwpView::OnUpdateParagraphCenter(CCmdUI* pCmdUI) 
{
	OnUpdateParaAlign(pCmdUI,PFA_CENTER);
	
}

void CEzwpView::OnCharacterItalic() 
{
	OnCharEffect(CFM_ITALIC,CFE_ITALIC);
	
}

void CEzwpView::OnUpdateCharacterItalic(CCmdUI* pCmdUI) 
{
	OnUpdateCharEffect(pCmdUI,CFM_ITALIC,CFE_ITALIC);
	
}

void CEzwpView::OnParagraphLeft() 
{
	OnParaAlign(PFA_LEFT);
	
}

void CEzwpView::OnUpdateParagraphLeft(CCmdUI* pCmdUI) 
{
	OnUpdateParaAlign(pCmdUI,PFA_LEFT);
	
}

void CEzwpView::OnParagraphRight() 
{
	OnParaAlign(PFA_RIGHT);
	
}

void CEzwpView::OnUpdateParagraphRight(CCmdUI* pCmdUI) 
{
	OnUpdateParaAlign(pCmdUI,PFA_RIGHT);
	
}

void CEzwpView::OnCharacterFont() 
{
CHARFORMAT cf;
cf=GetCharFormatSelection();
CFontDialog dlg(cf,CF_FORCEFONTEXIST|CF_INITTOLOGFONTSTRUCT|CF_SCREENFONTS);
if (dlg.DoModal()==IDOK)
{
	dlg.GetCharFormat(cf);
	SetCharFormat(cf);

}
	
}

void CEzwpView::OnStatistics() 
{
	CCharPage cp;
	CLinePage lp;
	CString tmp;
	CPropertySheet sheet("Statistics");
	sheet.AddPage(&cp);
	sheet.AddPage(&lp);
	tmp.Format("%d",GetTextLength());
	cp.m_count=tmp;
	tmp.Format("%d",GetRichEditCtrl().GetLineCount());
	lp.m_count=tmp;
	sheet.DoModal();	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -