【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-CBitmapShow_2View.cpp,希望本篇文章对您学习有所帮助。
// CBitmapShow_2View.cpp : implementation of the CCBitmapShow_2View class
//
#include "stdafx.h"
#include "CBitmapShow_2.h"
#include "CBitmapShow_2Doc.h"
#include "CBitmapShow_2View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_2View
IMPLEMENT_DYNCREATE(CCBitmapShow_2View, CView)
BEGIN_MESSAGE_MAP(CCBitmapShow_2View, CView)
//{{AFX_MSG_MAP(CCBitmapShow_2View)
ON_WM_ERASEBKGND()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_2View construction/destruction
CCBitmapShow_2View::CCBitmapShow_2View()
{
// TODO: add construction code here
}
CCBitmapShow_2View::~CCBitmapShow_2View()
{
}
BOOL CCBitmapShow_2View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_2View drawing
void CCBitmapShow_2View::OnDraw(CDC* pDC) //先擦除后贴,所以有闪烁
{
CCBitmapShow_2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_2View printing
BOOL CCBitmapShow_2View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCBitmapShow_2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCBitmapShow_2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_2View diagnostics
#ifdef _DEBUG
void CCBitmapShow_2View::AssertValid() const
{
CView::AssertValid();
}
void CCBitmapShow_2View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCBitmapShow_2Doc* CCBitmapShow_2View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCBitmapShow_2Doc)));
return (CCBitmapShow_2Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_2View message handlers
BOOL CCBitmapShow_2View::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBitmap bitmap; //创建位图
bitmap.LoadBitmap(IDB_BITMAP1);
BITMAP bmp;
bitmap.GetBitmap(&bmp);
CDC dcCompatible; //创建兼容DC
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(&bitmap); //将位图选到兼容DC中
CRect rect;
GetClientRect(&rect);
pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,bmp.bmWidth,
bmp.bmHeight,SRCCOPY); //将兼容DC的位图贴到当前DC中
return TRUE;
// return CView::OnEraseBkgnd(pDC);
}
上一篇:
CBitmapShow_2Doc.cpp
下一篇:
临床前药物安全性评价中毒性病理学新技术的应用