ex57View.cpp
资源名称:VC6.0.rar [点击查看]
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:3k
源码类别:
书籍源码
开发平台:
Visual C++
- // ex57View.cpp : implementation of the CEx57View class
- //
- #include "stdafx.h"
- #include "ex57.h"
- #include "ex57Doc.h"
- #include "ex57View.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEx57View
- IMPLEMENT_DYNCREATE(CEx57View, CView)
- BEGIN_MESSAGE_MAP(CEx57View, CView)
- //{{AFX_MSG_MAP(CEx57View)
- ON_WM_RBUTTONDOWN()
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CEx57View construction/destruction
- CEx57View::CEx57View()
- {
- // TODO: add construction code here
- }
- CEx57View::~CEx57View()
- {
- }
- BOOL CEx57View::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx57View drawing
- void CEx57View::OnDraw(CDC* pDC)
- {
- CEx57Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx57View printing
- BOOL CEx57View::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CEx57View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CEx57View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx57View diagnostics
- #ifdef _DEBUG
- void CEx57View::AssertValid() const
- {
- CView::AssertValid();
- }
- void CEx57View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CEx57Doc* CEx57View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx57Doc)));
- return (CEx57Doc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CEx57View message handlers
- void CEx57View::OnRButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CDC *pDC=GetDC();
- CFont myfont; //定义CFont类
- CFont*oldfont; //定义CFont类的指针
- myfont.CreateFont(-50,0,0,0,
- FW_NORMAL,FALSE,FALSE,FALSE,
- GB2312_CHARSET, //中文字符集
- OUT_STROKE_PRECIS,
- CLIP_STROKE_PRECIS,
- DRAFT_QUALITY,
- VARIABLE_PITCH|FF_MODERN,
- "楷体_GB2312"); //楷体
- oldfont=pDC->SelectObject(&myfont);
- pDC->TextOut(0,50,"这是自定义的楷体!");
- pDC->SelectObject(oldfont); //恢复原始字体
- CView::OnRButtonDown(nFlags, point);
- }