📄 vc11view.cpp
字号:
// vc11View.cpp : implementation of the CVc11View class
//
#include "stdafx.h"
#include "vc11.h"
#include "vc11Doc.h"
#include "vc11View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVc11View
IMPLEMENT_DYNCREATE(CVc11View, CEditView)
BEGIN_MESSAGE_MAP(CVc11View, CEditView)
//{{AFX_MSG_MAP(CVc11View)
ON_COMMAND(ID_FILE_PAGE_SETUP, OnPageSetup)
ON_COMMAND(ID_FILE_FONT_SETUP, OnFontSetup)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CVc11View construction/destruction
CVc11View::CVc11View()
{
// TODO: add construction code here
m_bpage=false;
m_bfont=false;
int fontsize;
fontsize=sizeof m_font;
memset(&m_font,0,fontsize);
strcpy(m_font.lfFaceName,_T("楷体_GB2312"));
m_font.lfHeight = 48;
m_font.lfWeight = 600;
m_font.lfOutPrecision=OUT_TT_PRECIS;
m_font.lfClipPrecision=CLIP_DEFAULT_PRECIS;
m_font.lfQuality=PROOF_QUALITY;
m_font.lfPitchAndFamily=FF_SWISS | VARIABLE_PITCH;
m_font.lfUnderline=1;
m_font.lfStrikeOut=1;
}
CVc11View::~CVc11View()
{
}
BOOL CVc11View::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;
}
/////////////////////////////////////////////////////////////////////////////
// CVc11View drawing
void CVc11View::OnDraw(CDC* pDC)
{
CVc11Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CVc11View printing
BOOL CVc11View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default CEditView preparation
pInfo->m_nNumPreviewPages = 2;
return CEditView::OnPreparePrinting(pInfo);
}
void CVc11View::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// Default CEditView begin printing.
CEditView::OnBeginPrinting(pDC, pInfo);
}
void CVc11View::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// Default CEditView end printing
CEditView::OnEndPrinting(pDC, pInfo);
}
/////////////////////////////////////////////////////////////////////////////
// CVc11View diagnostics
#ifdef _DEBUG
void CVc11View::AssertValid() const
{
CEditView::AssertValid();
}
void CVc11View::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
CVc11Doc* CVc11View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVc11Doc)));
return (CVc11Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CVc11View message handlers
void CVc11View::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
if(m_bpage)
{
SIZE PaperSize;
PaperSize.cx=m_page.ptPaperSize.x-m_page.rtMargin.left-m_page.rtMargin.right;
PaperSize.cy=m_page.ptPaperSize.y-m_page.rtMargin.top-m_page.rtMargin.bottom;
SIZE MargSize;
MargSize.cx=m_page.rtMargin.left;
MargSize.cy=m_page.rtMargin.top;
pDC->HIMETRICtoDP(&MargSize);
pDC->HIMETRICtoDP(&PaperSize);
RECT PRect;
PRect.left=MargSize.cx;
PRect.top=MargSize.cy;
PRect.right=MargSize.cx+PaperSize.cx;
PRect.bottom=MargSize.cy+PaperSize.cy;
pInfo->m_rectDraw=PRect;
}
CFont *tempf=NULL;
if(m_bfont)
{
CFont font;
LOGFONT templf=m_font;
templf.lfHeight=::MulDiv(templf.lfHeight,pDC->GetDeviceCaps(LOGPIXELSY),72);
if(!font.CreateFontIndirect(&templf))
AfxMessageBox("字体创建错误!");
else
{
tempf=pDC->SelectObject(&font);
if(tempf==NULL)
AfxMessageBox("字体选择错误!");
}
}
CEditView::OnPrint(pDC, pInfo);
if(m_bfont)
{
pDC->SelectObject(tempf);
}
}
void CVc11View::OnPageSetup()
{
// TODO: Add your command handler code here
CPageSetupDialog tempPage;
if(m_bpage)
{
tempPage.m_psd=m_page;
}
if(tempPage.DoModal()==IDOK)
{
m_bpage=true;
m_page=tempPage.m_psd;
}
}
void CVc11View::OnFontSetup()
{
// TODO: Add your command handler code here
CClientDC tempDC(NULL);
LOGFONT tempFont=m_font;
tempFont.lfHeight=::MulDiv(tempFont.lfHeight,tempDC.GetDeviceCaps(LOGPIXELSY),72);
CFontDialog m_fs(&tempFont);
if(m_fs.DoModal()==IDOK)
{
m_bfont=true;
tempFont.lfHeight=::MulDiv(tempFont.lfHeight,72,tempDC.GetDeviceCaps(LOGPIXELSY));
m_font=tempFont;
}
}
void CVc11View::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
pDC->SetMapMode(MM_TEXT);
CEditView::OnPrepareDC(pDC, pInfo);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -