📄 printview.cpp
字号:
// PrintView.cpp : implementation of the CPrintView class
//
#include "stdafx.h"
#include "htglxt.h"
#include "MyDoc.h"
#include "PrintView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPrintView
IMPLEMENT_DYNCREATE(CPrintView, CScrollView)
BEGIN_MESSAGE_MAP(CPrintView, CScrollView)
//{{AFX_MSG_MAP(CPrintView)
// 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, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrintView construction/destruction
CPrintView::CPrintView()
{
// TODO: add construction code here
}
CPrintView::~CPrintView()
{
}
BOOL CPrintView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CPrintView drawing
void CPrintView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int xPix=pDC->GetDeviceCaps(HORZRES);
int yPix=pDC->GetDeviceCaps(VERTRES);
BITMAP bitstruct;
bmp.GetBitmap(&bitstruct);
//变比载入图片
pDC->StretchBlt(0,0,xPix,yPix,&memDC,0,0,bitstruct.bmWidth,bitstruct.bmHeight,SRCCOPY);
//写入评审信息部分
CRect rect;
//pDC->SelectObject(&bmp);
pDC->TextOut(80,80,PrintID);
pDC->TextOut(300,80,sTprq);
pDC->TextOut(80,105,sXmmc);
pDC->TextOut(80,130,sXmgb);
pDC->TextOut(80,150,sXmyz);
pDC->TextOut(80,175,sHte);
pDC->TextOut(300,175,sDwbz);
rect=CRect(26,225,435,274);
pDC->DrawText(sTpfze,&rect,DT_WORDBREAK);
rect=CRect(26,293,435,358);
pDC->DrawText(sTpwtjfa,&rect,DT_WORDBREAK);
rect=CRect(26,390,435,455);
pDC->DrawText(sSsfagy,&rect,DT_WORDBREAK);
rect=CRect(26,480,435,545);
pDC->DrawText(sQt,&rect,DT_WORDBREAK);
pDC->TextOut(80,554,sPszcr);
pDC->TextOut(300,554,sShhbr);
//写入评审内容部分
rect=CRect(510,105,795,180);
pDC->DrawText(sPscjr,&rect,DT_WORDBREAK);
rect=CRect(510,215,795,320);
pDC->DrawText(sPsyj,&rect,DT_WORDBREAK);
rect=CRect(510,360,795,450);
pDC->DrawText(sBz,&rect,DT_WORDBREAK);
pDC->TextOut(570,462,sSpdd);
pDC->TextOut(570,486,sSpsj);
pDC->TextOut(570,510,sTbr);
pDC->TextOut(570,534,sTbsj);
pDC->TextOut(570,556,sSpqm);
// TODO: add draw code for native data here
}
void CPrintView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CDC * pDC;
pDC=this->GetDC();
memDC.CreateCompatibleDC(pDC);
bmp.LoadBitmap(IDB_BITPRINTVIEW);
memDC.SelectObject(&bmp);
BITMAP bits;
bmp.GetBitmap(&bits);
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx =bits.bmWidth-100;
sizeTotal.cy=bits.bmHeight+100;
SetScrollSizes(MM_TEXT, sizeTotal);
CString sSQL;
RxRecordset drst;
sSQL.Format("SELECT * FROM 签约前合同评审视图 WHERE 编号='%s'",PrintID);
drst.Open(sSQL,adCmdText);
if(drst.GetRecordCount()<1)
return;
sXmmc=drst.GetFieldValue("名称");
sXmyz=drst.GetFieldValue("项目业主");
sXmgb=drst.GetFieldValue("项目国别");
sHte=drst.GetFieldValue("合同额");
sDwbz=drst.GetFieldValue("单位币种");
sTprq=drst.GetFieldValue("谈判日期");
sTpfze=drst.GetFieldValue("谈判负责人");
sTpwtjfa=drst.GetFieldValue("谈判问题及方案");
sSsfagy=drst.GetFieldValue("实施方案概要");
sQt=drst.GetFieldValue("其他");
sPszcr=drst.GetFieldValue("评审主持人");
sShhbr=drst.GetFieldValue("评审汇报人");
sPscjr=drst.GetFieldValue("评审参加人");
sPsyj=drst.GetFieldValue("审批意见");
sSpqm=drst.GetFieldValue("审批签名");
sSpdd=drst.GetFieldValue("审评地点");
sSpsj=drst.GetFieldValue("审评时间");
sTbr=drst.GetFieldValue("填表人");
sTbsj=drst.GetFieldValue("填表时间");
sBz=drst.GetFieldValue("备注");
}
/////////////////////////////////////////////////////////////////////////////
// CPrintView printing
BOOL CPrintView::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
void CPrintView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
LPDEVMODE mode;
mode=pInfo->m_pPD->GetDevMode();
int xPix=pDC->GetDeviceCaps(HORZRES);
int yPix=pDC->GetDeviceCaps(VERTRES);
Ratio.x=(float)xPix/(float)mode->dmPaperWidth;
Ratio.y=(float)yPix/(float)mode->dmPaperLength;
}
void CPrintView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CPrintView diagnostics
#ifdef _DEBUG
void CPrintView::AssertValid() const
{
CScrollView::AssertValid();
}
void CPrintView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CMyDoc* CPrintView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPrintView message handlers
void CPrintView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
int xPix=pDC->GetDeviceCaps(HORZRES);
int yPix=pDC->GetDeviceCaps(VERTRES);
BITMAP bitstruct;
bmp.GetBitmap(&bitstruct);
pDC->SetMapMode(MM_TEXT);
CRect rect(0,0,xPix,yPix);
//变比载入图片
pDC->StretchBlt(xPix/10,yPix/10,xPix-2*(xPix/10),yPix-2*(yPix/10),&memDC,0,0,bitstruct.bmWidth,bitstruct.bmHeight,SRCCOPY);
//写入评审信息部分
pDC->TextOut(380*Ratio.x,620*Ratio.y,PrintID);
pDC->TextOut(840*Ratio.x,620*Ratio.y,sTprq);
pDC->TextOut(380*Ratio.x,710*Ratio.y,sXmmc);
pDC->TextOut(380*Ratio.x,810*Ratio.y,sXmgb);
pDC->TextOut(380*Ratio.x,890*Ratio.y,sXmyz);
pDC->TextOut(380*Ratio.x,990*Ratio.y,sHte);
pDC->TextOut(840*Ratio.x,990*Ratio.y,sDwbz);
rect=CRect(280*Ratio.x,1200*Ratio.y,xPix/20*11,(1370)*Ratio.y);
pDC->DrawText(sTpfze,&rect,DT_WORDBREAK);
rect=CRect(280*Ratio.x,1490*Ratio.y,xPix/20*11,(1690)*Ratio.y);
pDC->DrawText(sTpwtjfa,&rect,DT_WORDBREAK);
rect=CRect(280*Ratio.x,1850*Ratio.y,xPix/20*11,(2100)*Ratio.y);
pDC->DrawText(sSsfagy,&rect,DT_WORDBREAK);
rect=CRect(280*Ratio.x,2220*Ratio.y,xPix/20*11,(2460)*Ratio.y);
pDC->DrawText(sQt,&rect,DT_WORDBREAK);
pDC->TextOut(380*Ratio.x,2500*Ratio.y,sPszcr);
pDC->TextOut(840*Ratio.x,2500*Ratio.y,sShhbr);
//写入评审内容部分
rect=CRect(1300*Ratio.x,720*Ratio.y,xPix-240*Ratio.x,1000*Ratio.y);
pDC->DrawText(sPscjr,&rect,DT_WORDBREAK);
rect=CRect(1300*Ratio.x,1160*Ratio.y,xPix-240*Ratio.x,1560*Ratio.y);
pDC->DrawText(sPsyj,&rect,DT_WORDBREAK);
rect=CRect(1300*Ratio.x,1720*Ratio.y,xPix-240*Ratio.x,2080*Ratio.y);
pDC->DrawText(sBz,&rect,DT_WORDBREAK);
pDC->TextOut(1400*Ratio.x,2140*Ratio.y,sSpdd);
pDC->TextOut(1400*Ratio.x,2220*Ratio.y,sSpsj);
pDC->TextOut(1400*Ratio.x,2310*Ratio.y,sTbr);
pDC->TextOut(1400*Ratio.x,2400*Ratio.y,sTbsj);
pDC->TextOut(1400*Ratio.x,2500*Ratio.y,sSpqm);
//CScrollView::OnPrint(pDC, pInfo);
}
BOOL CPrintView::DestroyWindow()
{
memDC.DeleteDC();
bmp.DeleteObject();
return CScrollView::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -