【VC开源代码栏目提醒】:网学会员为需要VC开源代码的朋友们搜集整理了DrawBKView.cpp相关资料,希望对各位网友有所帮助!
// DrawBKView.cpp : implementation of the CDrawBKView class
//
#include "stdafx.h"
#include "DrawBK.h"
#include "DrawBKDoc.h"
#include "DrawBKView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDrawBKView
IMPLEMENT_DYNCREATE(CDrawBKView, CView)
BEGIN_MESSAGE_MAP(CDrawBKView, CView)
//{{AFX_MSG_MAP(CDrawBKView)
// 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, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDrawBKView construction/destruction
CDrawBKView::CDrawBKView()
{
// TODO: add construction code here
}
CDrawBKView::~CDrawBKView()
{
}
BOOL CDrawBKView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDrawBKView drawing
void CDrawBKView::OnDraw(CDC* pDC)
{
CDrawBKDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CBitmap m_Bitmap;
m_Bitmap.LoadBitmap(IDB_BITMAP1);
CDC memDC; //设备上下文
memDC.CreateCompatibleDC(pDC); //创建内存设备上下文
memDC.SelectObject(&m_Bitmap); //将位图选人设备上下文
BITMAP m_Bmp; //声明BITMAP对象
m_Bitmap.GetBitmap(&m_Bmp); //获得位图信息
int x = m_Bmp.bmWidth; //获得位图的宽度
int y = m_Bmp.bmHeight; //获得位图的高度
CRect rect; //声明区域对象
GetClientRect(rect); //获得编辑框客户区域
pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,x,y,SRCCOPY); //绘制位图背景
memDC.DeleteDC(); //释放内存设备上下文
}
/////////////////////////////////////////////////////////////////////////////
// CDrawBKView printing
BOOL CDrawBKView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDrawBKView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDrawBKView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDrawBKView diagnostics
#ifdef _DEBUG
void CDrawBKView::AssertValid() const
{
CView::AssertValid();
}
void CDrawBKView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDrawBKDoc* CDrawBKView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDrawBKDoc)));
return (CDrawBKDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDrawBKView message handlers
上一篇:
ConsoleUnit.pas
下一篇:
画一卷情长,念一世安好