📄 myimageview.cpp
字号:
// MyImageView.cpp : implementation of the CMyImageView class
//
#include "stdafx.h"
#include "MyImage.h"
#include "MyImageDoc.h"
#include "MyImageView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyImageView
IMPLEMENT_DYNCREATE(CMyImageView, CScrollView)
BEGIN_MESSAGE_MAP(CMyImageView, CScrollView)
//{{AFX_MSG_MAP(CMyImageView)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CMyImageView construction/destruction
CMyImageView::CMyImageView()
{
// TODO: add construction code here
}
CMyImageView::~CMyImageView()
{
}
BOOL CMyImageView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMyImageView drawing
void CMyImageView::OnDraw(CDC* pDC)
{
CMyImageDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CSize sz = pDoc->pic.GetSize();
pDoc->pic.Draw(pDC, 0,0,sz.cx,sz.cy,0,0,sz.cx,sz.cy);
}
void CMyImageView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
// SetScrollSizes(MM_TEXT, sizeTotal);
SetScrollSizes(MM_TEXT, GetDocument()->pic.GetSize());
}
/////////////////////////////////////////////////////////////////////////////
// CMyImageView printing
BOOL CMyImageView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMyImageView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMyImageView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMyImageView diagnostics
#ifdef _DEBUG
void CMyImageView::AssertValid() const
{
CScrollView::AssertValid();
}
void CMyImageView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CMyImageDoc* CMyImageView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyImageDoc)));
return (CMyImageDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyImageView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -