• 大小: 4KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-11
  • 语言: C/C++
  • 标签: MFC  打印  文档  VS2008  C++  

资源简介

1.调用方法_打印预览 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.调用方法_直接打印 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.参数设置 可设置打印方向,映射模式、打印页数等,测试样例使用的是DMORIENT_LANDSCAPE(横向打印),MM_LOMETRIC,10页 好用的话,大家给个好评哦

资源截图

代码片段和文件信息

// Printframe.cpp : 实现文件
//

#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: 在此添加专用代码和/或调用基类
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();
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4269  2016-06-09 21:26  PrintView.cpp

     文件        917  2016-06-09 21:43  PrintView.h

     文件        867  2016-06-09 21:39  说明.txt

     文件       1076  2016-06-09 21:13  Printframe.cpp

     文件        511  2016-06-09 21:42  Printframe.h

----------- ---------  ---------- -----  ----

                 7640                    5


评论

共有 条评论