【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了CBitmapShow_1View.cpp提供大家参考,希望对大家有所帮助!
// CBitmapShow_1View.cpp : implementation of the CCBitmapShow_1View class
//
#include "stdafx.h"
#include "CBitmapShow_1.h"
#include "CBitmapShow_1Doc.h"
#include "CBitmapShow_1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_1View
IMPLEMENT_DYNCREATE(CCBitmapShow_1View, CView)
BEGIN_MESSAGE_MAP(CCBitmapShow_1View, CView)
//{{AFX_MSG_MAP(CCBitmapShow_1View)
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_1View construction/destruction
CCBitmapShow_1View::CCBitmapShow_1View()
{
// TODO: add construction code here
}
CCBitmapShow_1View::~CCBitmapShow_1View()
{
}
BOOL CCBitmapShow_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_1View drawing
void CCBitmapShow_1View::OnDraw(CDC* pDC)
{
CCBitmapShow_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBitmap bitmap; //创建位图
bitmap.LoadBitmap(IDB_BITMAP2);
CDC dcCompatible; //创建兼容DC
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(&bitmap); //将位图选到兼容DC中
CRect rect;
GetClientRect(&rect);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
//将兼容DC的位图贴到当前DC中
//return TRUE;
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_1View printing
BOOL CCBitmapShow_1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCBitmapShow_1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCBitmapShow_1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_1View diagnostics
#ifdef _DEBUG
void CCBitmapShow_1View::AssertValid() const
{
CView::AssertValid();
}
void CCBitmapShow_1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCBitmapShow_1Doc* CCBitmapShow_1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCBitmapShow_1Doc)));
return (CCBitmapShow_1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCBitmapShow_1View message handlers
BOOL CCBitmapShow_1View::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
/*
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
return TRUE;
*/
return CView::OnEraseBkgnd(pDC); //不能调用基类
}
上一篇:
CBitmapShow_1Doc.cpp
下一篇:
爱情只不过就是,爱与不爱