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

📄 metafileview.cpp

📁 MFC程序开发参考大全 【明日科技】宋坤 刘锐宁 李伟明 【丛 书 名】 软件工程师典藏 【出 版 社】 人民邮电出版社 本书详细介绍了MFC框架中所有常用类及控件的应用
💻 CPP
字号:
// MetaFileView.cpp : implementation of the CMetaFileView class
//

#include "stdafx.h"
#include "MetaFile.h"

#include "MetaFileDoc.h"
#include "MetaFileView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMetaFileView

IMPLEMENT_DYNCREATE(CMetaFileView, CView)

BEGIN_MESSAGE_MAP(CMetaFileView, CView)
	//{{AFX_MSG_MAP(CMetaFileView)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CMetaFileView construction/destruction

CMetaFileView::CMetaFileView()
{

	metadc.Create();
}

CMetaFileView::~CMetaFileView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMetaFileView drawing

void CMetaFileView::OnDraw(CDC* pDC)
{
	CMetaFileDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	
	metadc.MoveTo(20,20);
	metadc.LineTo(20,100);
	metadc.Ellipse(70,70,150,150);
	metadc.Rectangle(50,170,200,200);

	HMETAFILE playfile;
	playfile=metadc.Close();
	pDC->PlayMetaFile(playfile);
	DeleteMetaFile(playfile);

	HMETAFILE savefile;
	savefile=metadc.Close();
	CopyMetaFile(savefile,"myfile.wmf");
	metadc.Create("myfile.wmf");
	DeleteMetaFile(savefile);

}

/////////////////////////////////////////////////////////////////////////////
// CMetaFileView printing

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

void CMetaFileView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMetaFileView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMetaFileView diagnostics

#ifdef _DEBUG
void CMetaFileView::AssertValid() const
{
	CView::AssertValid();
}

void CMetaFileView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CMetaFileView message handlers

⌨️ 快捷键说明

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