// mymfc26AView.cpp : implementation of the CMymfc26AView class
//

#include "stdafx.h"
#include "mymfc26A.h"

#include "mymfc26ADoc.h"
#include "mymfc26AView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMymfc26AView

IMPLEMENT_DYNCREATE(CMymfc26AView, CScrollView)

BEGIN_MESSAGE_MAP(CMymfc26AView, CScrollView)
	//{{AFX_MSG_MAP(CMymfc26AView)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CMymfc26AView construction/destruction

CMymfc26AView::CMymfc26AView()
{
	// TODO: add construction code here
	m_pdcMemory = new CDC;
    m_pBitmap = new CBitmap;
}

CMymfc26AView::~CMymfc26AView()
{
	// cleans up the memory device context and the bitmap
    delete m_pdcMemory; // deselects bitmap
    delete m_pBitmap;
}

BOOL CMymfc26AView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CScrollView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc26AView drawing

void CMymfc26AView::OnDraw(CDC* pDC)
{
	pDC->SetStretchBltMode(COLORONCOLOR);
    pDC->StretchBlt(20, -20, m_sizeDest.cx, -m_sizeDest.cy,
        m_pdcMemory, 0, 0,
        m_sizeSource.cx, m_sizeSource.cy, SRCCOPY);

    pDC->StretchBlt(350, -20, m_sizeSource.cx, -m_sizeSource.cy,
        m_pdcMemory, 0, 0,
        m_sizeSource.cx, m_sizeSource.cy, SRCCOPY);
}

void CMymfc26AView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();
    CSize sizeTotal(800, 1050); // 8-by-10.5 inches
    CSize sizeLine = CSize(sizeTotal.cx / 100, sizeTotal.cy / 100);
    SetScrollSizes(MM_LOENGLISH, sizeTotal, sizeTotal, sizeLine);

    BITMAP bm; // Windows BITMAP data structure; see Win32 help
    if (m_pdcMemory->GetSafeHdc() == NULL) {
        CClientDC dc(this);
        OnPrepareDC(&dc); // necessary
		//Change the ID to your own bitmap if any
        m_pBitmap->LoadBitmap(IDB_SOAPBUBBLE);
        m_pdcMemory->CreateCompatibleDC(&dc);
        m_pdcMemory->SelectObject(m_pBitmap);
        m_pBitmap->GetObject(sizeof(bm), &bm);
        m_sizeSource.cx = bm.bmWidth;
        m_sizeSource.cy = bm.bmHeight;
        m_sizeDest = m_sizeSource;
        dc.DPtoLP(&m_sizeDest);
    }
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc26AView printing

BOOL CMymfc26AView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMymfc26AView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMymfc26AView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc26AView diagnostics

#ifdef _DEBUG
void CMymfc26AView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CMymfc26AView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}

CMymfc26ADoc* CMymfc26AView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMymfc26ADoc)));
	return (CMymfc26ADoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMymfc26AView message handlers

