資源簡(jiǎn)介
1.調(diào)用方法_打印預(yù)覽
CPrintFrame* pWndPrint = new CPrintFrame;
CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CPrintView);
context.m_pCurrentFrame = pWndPrint;
context.m_pCurrentDoc = NULL;
context.m_pLastView = NULL;
pWndPrint->Create(NULL,"打印",WS_OVERLAPPEDWINDOW,CFrameWnd::rectDefault,
NULL,NULL,0,&context);
pWndPrint->PrintPreview();
2.調(diào)用方法_直接打印
CPrintFrame* pWndPrint = new CPrintFrame;
CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CPrintView);
context.m_pCurrentFrame = pWndPrint;
context.m_pCurrentDoc = NULL;
context.m_pLastView = NULL;
pWndPrint->Create(NULL,"打印",WS_OVERLAPPEDWINDOW,CFrameWnd::rectDefault,
NULL,NULL,0,&context);
pWndPrint->Print();
3.參數(shù)設(shè)置
可設(shè)置打印方向,映射模式、打印頁(yè)數(shù)等,測(cè)試樣例使用的是DMORIENT_LANDSCAPE(橫向打印),MM_LOMETRIC,10頁(yè)
好用的話(huà),大家給個(gè)好評(píng)哦

代碼片段和文件信息
//?Printframe.cpp?:?實(shí)現(xiàn)文件
//
#include?“stdafx.h“
#include?“Printframe.h“
//?CPrintframe
IMPLEMENT_DYNCREATE(CPrintframe?CframeWnd)
CPrintframe::CPrintframe()
{
}
CPrintframe::~CPrintframe()
{
}
BEGIN_MESSAGE_MAP(CPrintframe?CframeWnd)
ON_WM_CREATE()
ON_WM_CLOSE()
END_MESSAGE_MAP()
//?CPrintframe?消息處理程序
int?CPrintframe::OnCreate(LPCREATESTRUCT?lpCreateStruct)
{
if?(CframeWnd::OnCreate(lpCreateStruct)?==?-1)
return?-1;
SetActiveView((CPrintView*)GetDescendantWindow(AFX_IDW_PANE_FIRSTTRUE));
return?0;
}
BOOL?CPrintframe::OnCreateClient(LPCREATESTRUCT?lpcs?CCreateContext*?pContext)
{
//?TODO:?在此添加專(zhuān)用代碼和/或調(diào)用基類(lèi)
return?CframeWnd::OnCreateClient(lpcs?pContext);
}
void?CPrintframe::Print()
{
GetActiveView()->SendMessage(WM_COMMANDMAKELONG(ID_FILE_PRINT0)NULL);
}
void?CPrintframe::PrintPreview()
{
GetActiveView()->SendMessage(WM_COMMANDMAKELONG(ID_FILE_PRINT_PREVIEW0)NULL);
ShowWindow(SW_MAXIMIZE);
}
void?CPrintframe::OnClose()
{
CframeWnd::OnClose();
}
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????4269??2016-06-09?21:26??PrintView.cpp
?????文件????????917??2016-06-09?21:43??PrintView.h
?????文件????????867??2016-06-09?21:39??說(shuō)明.txt
?????文件???????1076??2016-06-09?21:13??Printfr
?????文件????????511??2016-06-09?21:42??Printfr
-----------?---------??----------?-----??----
?????????????????7640????????????????????5
評(píng)論
共有 條評(píng)論