bmpviewerview.cpp

来自「vc++ study」· C++ 代码 · 共 116 行

CPP
116
字号
// BmpViewerView.cpp : implementation of the CBmpViewerView class
//

#include "stdafx.h"
#include "BmpViewer.h"

#include "BmpViewerDoc.h"
#include "BmpViewerView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBmpViewerView

IMPLEMENT_DYNCREATE(CBmpViewerView, CScrollView)

BEGIN_MESSAGE_MAP(CBmpViewerView, CScrollView)
	//{{AFX_MSG_MAP(CBmpViewerView)
		// 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
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBmpViewerView construction/destruction

CBmpViewerView::CBmpViewerView()
{
	// TODO: add construction code here

}

CBmpViewerView::~CBmpViewerView()
{
}

BOOL CBmpViewerView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CScrollView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CBmpViewerView drawing

void CBmpViewerView::OnDraw(CDC* pDC)
{
	CBmpViewerDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	pDoc->Draw(pDC);
}

void CBmpViewerView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	CBmpViewerDoc *pDoc=GetDocument();
	CSize size=pDoc->GetImageSize();
	SetScrollSizes(MM_TEXT, size);
}

/////////////////////////////////////////////////////////////////////////////
// CBmpViewerView diagnostics

#ifdef _DEBUG
void CBmpViewerView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CBmpViewerView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}

CBmpViewerDoc* CBmpViewerView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBmpViewerDoc)));
	return (CBmpViewerDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CBmpViewerView message handlers

BOOL CBmpViewerView::RealizePalette(BOOL back)
{
  UNIT nColors;
  CClientDC dc(this);
  nColors=DrawDibRealize(GetDocument()->GetDrawDib(),dc.GetSafeHdc(),back);
  if((nColors>0)||back)
  {
	  Invalidate();
	  return nColors;
}

void CBmpViewerView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	//CScrollView::OnActivateView(bActivate, pActivateView, pDeactiveView);
	if(bActivate)
	{
		RealizePalette(FALSE);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?