📄 imagetoolview.cpp
字号:
// ImageToolView.cpp : implementation of the CImageToolView class
//
#include "stdafx.h"
#include "ImageTool.h"
#include "ImageToolDoc.h"
#include "ImageToolView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CImageToolView
IMPLEMENT_DYNCREATE(CImageToolView, CScrollView)
BEGIN_MESSAGE_MAP(CImageToolView, CScrollView)
//{{AFX_MSG_MAP(CImageToolView)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CImageToolView construction/destruction
CImageToolView::CImageToolView()
{
// TODO: add construction code here
}
CImageToolView::~CImageToolView()
{
}
BOOL CImageToolView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CImageToolView drawing
void CImageToolView::OnDraw(CDC* pDC)
{
CImageToolDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if(pDoc->m_hBitmap)
{
CBitmap bmp;
bmp.Attach(pDoc->m_hBitmap);
// Get the size of the bitmap
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
// Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
pDC->BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCCOPY);
dcMemory.SelectObject(&pOldBitmap);
bmp.Detach();
}
}
void CImageToolView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 0;
SetScrollSizes(MM_TEXT, GetDocument()->GetViewSize() );
//SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CImageToolView printing
BOOL CImageToolView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CImageToolView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CImageToolView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CImageToolView diagnostics
#ifdef _DEBUG
void CImageToolView::AssertValid() const
{
CScrollView::AssertValid();
}
void CImageToolView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CImageToolDoc* CImageToolView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CImageToolDoc)));
return (CImageToolDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CImageToolView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -