【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了PrintDriverNameView.cpp提供大家参考,希望对大家有所帮助!
// PrintDriverNameView.cpp : implementation of the CPrintDriverNameView class
//
#include "stdafx.h"
#include "PrintDriverName.h"
#include "PrintDriverNameDoc.h"
#include "PrintDriverNameView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPrintDriverNameView
IMPLEMENT_DYNCREATE(CPrintDriverNameView, CView)
BEGIN_MESSAGE_MAP(CPrintDriverNameView, CView)
//{{AFX_MSG_MAP(CPrintDriverNameView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CPrintDriverNameView construction/destruction
CPrintDriverNameView::CPrintDriverNameView()
{
// TODO: add construction code here
}
CPrintDriverNameView::~CPrintDriverNameView()
{
}
BOOL CPrintDriverNameView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CPrintDriverNameView drawing
void CPrintDriverNameView::OnDraw(CDC* pDC)
{
CPrintDriverNameDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->TextOut(0,0,"请点击文件菜单下的打印菜单项!");
}
/////////////////////////////////////////////////////////////////////////////
// CPrintDriverNameView printing
BOOL CPrintDriverNameView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CPrintDriverNameView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
CPrintDialog printDlg(FALSE);//构造打印设置对话框对象
printDlg.GetDefaults();//检取缺省打印设备的设备环境
CString strDriver=printDlg.GetDriverName();
AfxMessageBox("打印机驱动程序名称:\n"+strDriver);
}
void CPrintDriverNameView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CPrintDriverNameView diagnostics
#ifdef _DEBUG
void CPrintDriverNameView::AssertValid() const
{
CView::AssertValid();
}
void CPrintDriverNameView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CPrintDriverNameDoc* CPrintDriverNameView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPrintDriverNameDoc)));
return (CPrintDriverNameDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPrintDriverNameView message handlers