?? bmpimgageview.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 + -