www.pudn.com > IFSEditor.rar > IFSEditorView.cpp


// IFSEditorView.cpp : implementation of the CIFSEditorView class 
// 
 
#include "stdafx.h" 
#include "IFSEditor.h" 
 
#include "IFSEditorDoc.h" 
#include "IFSEditorView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CIFSEditorView 
 
IMPLEMENT_DYNCREATE(CIFSEditorView, CScrollView) 
 
BEGIN_MESSAGE_MAP(CIFSEditorView, CScrollView) 
	//{{AFX_MSG_MAP(CIFSEditorView) 
	ON_WM_ERASEBKGND() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CIFSEditorView construction/destruction 
 
CIFSEditorView::CIFSEditorView() 
{ 
	// TODO: add construction code here 
 
} 
 
CIFSEditorView::~CIFSEditorView() 
{ 
} 
 
BOOL CIFSEditorView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CScrollView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CIFSEditorView drawing 
 
void CIFSEditorView::OnDraw(CDC* pDC) 
{ 
	CIFSEditorDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
 
	if(GetDocument()->GetValid()) 
	{ 
		CDC memdc; 
		CBitmap *pOldBmp; 
		memdc.CreateCompatibleDC(pDC); 
		pOldBmp = (CBitmap *)memdc.SelectObject(GetDocument()->GetBitmap()); 
		pDC->BitBlt(0, 0, GetDocument()->GetWidth(), GetDocument()->GetHeight(), &memdc, 0, 0, SRCCOPY); 
		memdc.SelectObject(pOldBmp); 
		memdc.DeleteDC(); 
	} 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CIFSEditorView diagnostics 
 
#ifdef _DEBUG 
void CIFSEditorView::AssertValid() const 
{ 
	CScrollView::AssertValid(); 
} 
 
void CIFSEditorView::Dump(CDumpContext& dc) const 
{ 
	CScrollView::Dump(dc); 
} 
 
CIFSEditorDoc* CIFSEditorView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CIFSEditorDoc))); 
	return (CIFSEditorDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CIFSEditorView message handlers 
 
void CIFSEditorView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	if(GetDocument()->GetValid()) 
	{ 
		SetScrollSizes(MM_TEXT, CSize(GetDocument()->GetWidth(), GetDocument()->GetHeight())); 
	} 
	else 
	{ 
		SetScrollSizes(MM_TEXT, CSize(0, 0)); 
	} 
	CScrollView::OnUpdate(pSender, lHint, pHint); 
} 
 
BOOL CIFSEditorView::OnEraseBkgnd(CDC* pDC)  
{ 
	// TODO: Add your message handler code here and/or call default 
	CBrush GrayBrush; 
	CRect rt; 
	GrayBrush.CreateSolidBrush(RGB(128, 128, 128)); 
	GetClientRect(rt); 
	if(GetDocument()->GetValid()) 
	{ 
		CRect rtBmp(0, 0, GetDocument()->GetWidth(), GetDocument()->GetHeight()); 
		pDC->LPtoDP(rtBmp); 
		rt.left += rtBmp.right; 
		pDC->FillRect(rt, &GrayBrush); 
		rt.left -= rtBmp.right; 
		rt.top += rtBmp.bottom; 
		pDC->FillRect(rt, &GrayBrush); 
	} 
	else 
	{ 
		pDC->FillRect(rt, &GrayBrush); 
	} 
	GrayBrush.DeleteObject(); 
	return TRUE; 
}