?? wyspview.cpp
字號:
// wyspView.cpp : implementation of the CWyspView class
//
#include "stdafx.h"
#include "htglxt.h"
#include "MyDoc.h"
#include "wyspView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWyspView
IMPLEMENT_DYNCREATE(CWyspView, CScrollView)
BEGIN_MESSAGE_MAP(CWyspView, CScrollView)
//{{AFX_MSG_MAP(CWyspView)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CWyspView construction/destruction
CWyspView::CWyspView()
{
// TODO: add construction code here
}
CWyspView::~CWyspView()
{
}
BOOL CWyspView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CWyspView drawing
void CWyspView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
Print(0.378, 0.2,pDC);
}
void CWyspView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CDC * pDC;
pDC=this->GetDC();
memDC.CreateCompatibleDC(pDC);
bmp.LoadBitmap(IDB_WYSPVIEW);
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);
if(PrintID.IsEmpty())
return;
CString sSQL;
RxRecordset drst;
sSQL.Format("SELECT * FROM 違約索賠視圖 WHERE 編號='%s'",PrintID);
drst.Open(sSQL,adCmdText);
if(drst.GetRecordCount()<1)
return;
sHTBH=drst.GetFieldValue("合同號");
sXMMC=drst.GetFieldValue("項目名稱");
sBMMC=drst.GetFieldValue("部門名稱");
sWTRQ=drst.GetFieldValue("問題日期");
sWTNR=drst.GetFieldValue("問題內容");
sJSJG=drst.GetFieldValue("交涉結果");
sFZE=drst.GetFieldValue("負責人");
sSPQK=drst.GetFieldValue("索賠情況");
}
/////////////////////////////////////////////////////////////////////////////
// CWyspView printing
BOOL CWyspView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CWyspView::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 CWyspView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CWyspView diagnostics
#ifdef _DEBUG
void CWyspView::AssertValid() const
{
CScrollView::AssertValid();
}
void CWyspView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CMyDoc* CWyspView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWyspView message handlers
BOOL CWyspView::DestroyWindow()
{
memDC.DeleteDC();
bmp.DeleteObject();
return CScrollView::DestroyWindow();
}
void CWyspView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
Print(Ratio.x, Ratio.y,pDC);
//CScrollView::OnPrint(pDC, pInfo);
}
void CWyspView::Print(float x, float y, CDC *pDC)
{
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/15,yPix/15,xPix-2*(xPix/15),yPix-2*(yPix/15),&memDC,0,0,bitstruct.bmWidth,bitstruct.bmHeight,SRCCOPY);
pDC->TextOut(450*x,512*y,PrintID);
pDC->TextOut(1250*x,512*y,sHTBH);
pDC->TextOut(450*x,603*y,sBMMC);
pDC->TextOut(1250*x,603*y,sXMMC);
pDC->TextOut(540*x,695*y,sWTRQ);
rect=CRect(300*x,875*y,xPix-(300*x),1600*y );
pDC->DrawText(sWTNR,&rect,DT_WORDBREAK);
rect=CRect(300*x,1795*y,xPix-(300*x),2500*y );
pDC->DrawText(sJSJG,&rect,DT_WORDBREAK);
pDC->TextOut(500*x,2550*y,sFZE);
pDC->TextOut(1060*x,2555*y,sSPQK);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -