imagshowview.cpp
来自「VC++6开发指南的源代码第24章-第25章」· C++ 代码 · 共 121 行
CPP
121 行
// ImagShowView.cpp : implementation of the CImagShowView class
//
#include "stdafx.h"
#include "ImagShow.h"
#include "ImagShowDoc.h"
#include "ImagShowView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CImagShowView
IMPLEMENT_DYNCREATE(CImagShowView, CView)
BEGIN_MESSAGE_MAP(CImagShowView, CView)
//{{AFX_MSG_MAP(CImagShowView)
// 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, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CImagShowView construction/destruction
CImagShowView::CImagShowView()
{
// TODO: add construction code here
}
CImagShowView::~CImagShowView()
{
}
BOOL CImagShowView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CImagShowView drawing
void CImagShowView::OnDraw(CDC* pDC)
{
CImagShowDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
HGLOBAL hDIB = pDoc->GetHObject();
if (hDIB != NULL) // 判断DIB是否为空
{
LPSTR lpDibSection = (LPSTR) ::GlobalLock(hDIB);
int cxDIB = (int) pDoc->m_dib.GetWidth(lpDibSection); // 获取DIB宽度
int cyDIB = (int) pDoc->m_dib.GetHeight(lpDibSection); // 获取DIB高度
::GlobalUnlock(hDIB);
CRect rcDIB;
rcDIB.top = rcDIB.left = 0;
rcDIB.right = cxDIB;
rcDIB.bottom = cyDIB;
CRect rcDest= rcDIB;
pDoc->m_dib.DrawDib(pDC->m_hDC, &rcDest, pDoc->GetHObject(),// 重画DIB
&rcDIB, pDoc->GetDocPal());
}
}
/////////////////////////////////////////////////////////////////////////////
// CImagShowView printing
BOOL CImagShowView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CImagShowView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CImagShowView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CImagShowView diagnostics
#ifdef _DEBUG
void CImagShowView::AssertValid() const
{
CView::AssertValid();
}
void CImagShowView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CImagShowDoc* CImagShowView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CImagShowDoc)));
return (CImagShowDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CImagShowView message handlers
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?