📄 chapter09aview.cpp
字号:
// Chapter09AView.cpp : implementation of the CChapter09AView class
//
#include "stdafx.h"
#include "Chapter09A.h"
#include "Chapter09ADoc.h"
#include "Chapter09AView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChapter09AView
IMPLEMENT_DYNCREATE(CChapter09AView, CEditView)
BEGIN_MESSAGE_MAP(CChapter09AView, CEditView)
//{{AFX_MSG_MAP(CChapter09AView)
ON_COMMAND(ID_FONT_CFG, OnFontCfg)
//}}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)
ON_MESSAGE(WM_USER_APPLY, OnApply)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChapter09AView construction/destruction
CChapter09AView::CChapter09AView():m_FontSheet("字体配置")
{
// TODO: add construction code here
}
CChapter09AView::~CChapter09AView()
{
}
BOOL CChapter09AView::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;
}
/////////////////////////////////////////////////////////////////////////////
// CChapter09AView drawing
void CChapter09AView::OnDraw(CDC* pDC)
{
CChapter09ADoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CChapter09AView printing
BOOL CChapter09AView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default CEditView preparation
return CEditView::OnPreparePrinting(pInfo);
}
void CChapter09AView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// Default CEditView begin printing.
CEditView::OnBeginPrinting(pDC, pInfo);
}
void CChapter09AView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// Default CEditView end printing
CEditView::OnEndPrinting(pDC, pInfo);
}
/////////////////////////////////////////////////////////////////////////////
// CChapter09AView diagnostics
#ifdef _DEBUG
void CChapter09AView::AssertValid() const
{
CEditView::AssertValid();
}
void CChapter09AView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
CChapter09ADoc* CChapter09AView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CChapter09ADoc)));
return (CChapter09ADoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChapter09AView message handlers
BOOL CChapter09AView::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
if(pNewFont)
delete pNewFont;
return CEditView::DestroyWindow();
}
void CChapter09AView::OnFontCfg()
{
// TODO: Add your command handler code here
m_FontSheet.DoModal();
}
void CChapter09AView::OnApply(WPARAM wParam, LPARAM lParam)
{
//获取编辑视所包含的编辑控件
CEdit& MessageBody=GetEditCtrl();
CString str;
//设置正文中的字体
LOGFONT logft;
//获取字体大小属性
logft.lfHeight=m_FontSheet.m_Size.m_Height;
logft.lfWidth=m_FontSheet.m_Size.m_Width;
logft.lfEscapement=0;
//获取效果
logft.lfWeight=m_FontSheet.m_Effect.m_bBold?FW_BOLD:FW_NORMAL;
logft.lfItalic=m_FontSheet.m_Effect.m_bItalic;//
logft.lfUnderline =m_FontSheet.m_Effect.m_bUnderline;
//设置为系统字体
m_FontSheet.m_Font.m_lstFont.GetText(\
m_FontSheet.m_Font.m_lstFont.GetCurSel(),str);
logft.lfStrikeOut=FALSE;
//解析字体和字符集
strcpy(logft.lfFaceName,str.Left(str.Find("+")));
logft.lfCharSet=atoi(str.Mid(str.Find("+")));
//new出来的对象需要在适当时候手工删除,别忘记了
pNewFont=new CFont();
pNewFont->CreateFontIndirect(&logft);
//设置编辑控件字体
MessageBody.SetFont(pNewFont,FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -