⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmpimgageview.cpp

📁 打开一个bmp影像
💻 CPP
字号:
// BMPIMGAGEView.cpp : implementation of the CBMPIMGAGEView class
//

#include "stdafx.h"
#include "BMPIMGAGE.h"

#include "BMPIMGAGEDoc.h"
#include "BMPIMGAGEView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBMPIMGAGEView

IMPLEMENT_DYNCREATE(CBMPIMGAGEView, CScrollView)

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

/////////////////////////////////////////////////////////////////////////////
// CBMPIMGAGEView construction/destruction

CBMPIMGAGEView::CBMPIMGAGEView()
{
	// TODO: add construction code here
   m_fScale = 2.0;
}

CBMPIMGAGEView::~CBMPIMGAGEView()
{
}

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

	return CScrollView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CBMPIMGAGEView drawing

void CBMPIMGAGEView::OnDraw(CDC* pDC)
{
	CBMPIMGAGEDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here


	BeginWaitCursor();
	if(pDoc->m_FileFlag)
	{	
		//客户区的空白区域设置为黑色
		CRect r;
		GetClientRect(&r);
		CPoint point = GetScrollPosition();
	
		r.right  += point.x;
		r.bottom += point.y;
		CBrush brush(RGB(0,0,0));
		pDC->FillRect(&r,&brush);
		//显示图像
		int RectWidth  = (int)( pDoc->m_Dib.GetImageWidth()  * m_fScale );
		int RectHeight = (int)( pDoc->m_Dib.GetImageHeight() * m_fScale );
		CSize size(RectWidth,RectHeight);
        SetScrollSizes(MM_TEXT,size);
		//SetTotalSize(MM_TEXT,size);
		pDoc->m_Dib.Draw(pDC, 0, 0, RectWidth, RectHeight);

	}
	EndWaitCursor();
}

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

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = sizeTotal.cy = 100;
	SetScrollSizes(MM_TEXT, sizeTotal);
}

/////////////////////////////////////////////////////////////////////////////
// CBMPIMGAGEView printing

BOOL CBMPIMGAGEView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CBMPIMGAGEView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CBMPIMGAGEView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CBMPIMGAGEView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CBMPIMGAGEView message handlers

⌨️ 快捷键说明

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