www.pudn.com > PKEncodeDemo.zip > SampleView.cpp


// SampleView.cpp : implementation of the CSampleView class 
// 
 
#include "stdafx.h" 
#include "Sample.h" 
 
#include "SampleDoc.h" 
#include "SampleView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleView 
 
IMPLEMENT_DYNCREATE(CSampleView, CScrollView) 
 
BEGIN_MESSAGE_MAP(CSampleView, CScrollView) 
	//{{AFX_MSG_MAP(CSampleView) 
		// 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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleView construction/destruction 
 
CSampleView::CSampleView() 
{ 
	// TODO: add construction code here 
 
} 
 
CSampleView::~CSampleView() 
{ 
} 
 
BOOL CSampleView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CScrollView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleView drawing 
   
void CSampleView::OnDraw(CDC* pDC) 
{ 
	CSampleDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
	CRect rect; 
	int sizeX= int(1.2*pDoc->m_image.dwWidth); 
	int sizeY= int(1.2*pDoc->m_image.dwHeight); 
	GetWindowRect(&rect); 
	CBrush brush( HS_DIAGCROSS   , RGB(218, 218, 218) ); 
	CBrush* pOldBrush=pDC->SelectObject(&brush); 
	pDC->Rectangle(0,0, __max(sizeX, rect.Width()), __max(sizeY,rect.Height()) ); 
    pDC->SelectObject(pOldBrush); 
	 
	if( pDoc->m_image.pBits == NULL) 
		return; 
	PtShowImage( &pDoc->m_image, pDC->GetSafeHdc () , 10, 10, 1.0 ); 
	 
    /*CSize sizeTotal( int(1.2*pDoc->m_image.width ), int(1.2*pDoc->m_image.height) ); 
	CSize sizePage(sizeTotal.cx/2, sizeTotal.cy/2); 
    CSize sizeLine(sizeTotal.cx/10, sizeTotal.cy/10); 
	SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine);*/ 
} 
 
void CSampleView::OnInitialUpdate() 
{  
	CScrollView::OnInitialUpdate(); 
 
	CSize sizeTotal; 
	// TODO: calculate the total size of this view 
	sizeTotal.cx = sizeTotal.cy = 100; 
	SetScrollSizes(MM_TEXT, sizeTotal); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleView printing 
 
BOOL CSampleView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CSampleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CSampleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleView diagnostics 
 
#ifdef _DEBUG 
void CSampleView::AssertValid() const 
{ 
	CScrollView::AssertValid(); 
} 
 
void CSampleView::Dump(CDumpContext& dc) const 
{ 
	CScrollView::Dump(dc); 
} 
 
CSampleDoc* CSampleView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSampleDoc))); 
	return (CSampleDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleView message handlers