ShowBMPView.cpp
资源名称:ShowBMP.rar [点击查看]
上传用户:zhuahui520
上传日期:2022-07-26
资源大小:344k
文件大小:3k
源码类别:
对话框与窗口
开发平台:
Visual C++
- // ShowBMPView.cpp : implementation of the CShowBMPView class
- //
- #include "stdafx.h"
- #include "ShowBMP.h"
- #include "ShowBMPDoc.h"
- #include "ShowBMPView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CShowBMPView
- IMPLEMENT_DYNCREATE(CShowBMPView, CView)
- BEGIN_MESSAGE_MAP(CShowBMPView, CView)
- //{{AFX_MSG_MAP(CShowBMPView)
- // 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()
- /////////////////////////////////////////////////////////////////////////////
- // CShowBMPView construction/destruction
- CShowBMPView::CShowBMPView()
- {
- // TODO: add construction code here
- }
- CShowBMPView::~CShowBMPView()
- {
- }
- BOOL CShowBMPView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CShowBMPView drawing
- void CShowBMPView::OnDraw(CDC* pDC)
- {
- CShowBMPDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- CDC MemDC;
- MemDC.CreateCompatibleDC(pDC);
- CBitmap Bitmap;
- Bitmap.LoadBitmap(IDB_SHOWBITMAP);
- CBitmap*pOldBitmap=MemDC.SelectObject(&Bitmap);
- BITMAP bm;
- Bitmap.GetObject(sizeof(BITMAP),&bm);//讀取位圖信息
- pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&MemDC,0,0,SRCCOPY);
- MemDC.SelectObject(pOldBitmap);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CShowBMPView printing
- BOOL CShowBMPView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CShowBMPView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CShowBMPView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CShowBMPView diagnostics
- #ifdef _DEBUG
- void CShowBMPView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CShowBMPView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CShowBMPDoc* CShowBMPView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CShowBMPDoc)));
- return (CShowBMPDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CShowBMPView message handlers