CCachedScrollViewPView.cpp
资源名称:08.zip [点击查看]
上传用户:ynjin1970
上传日期:2014-10-13
资源大小:6438k
文件大小:4k
源码类别:
中间件编程
开发平台:
Visual C++
- // CCachedScrollViewPView.cpp : implementation of the CCCachedScrollViewPView class
- //
- #include "stdafx.h"
- #include "CCachedScrollViewP.h"
- #include "mainfrm.h"
- #include "CCachedScrollViewPDoc.h"
- #include "CCachedScrollViewPView.h"
- #include "CachedScrollView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CCCachedScrollViewPView
- IMPLEMENT_DYNCREATE(CCCachedScrollViewPView, CCachedScrollView)
- BEGIN_MESSAGE_MAP(CCCachedScrollViewPView, CCachedScrollView)
- //{{AFX_MSG_MAP(CCCachedScrollViewPView)
- // 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, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CCCachedScrollViewPView construction/destruction
- CCCachedScrollViewPView::CCCachedScrollViewPView()
- {
- // TODO: add construction code here
- }
- CCCachedScrollViewPView::~CCCachedScrollViewPView()
- {
- }
- BOOL CCCachedScrollViewPView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CScrollView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCCachedScrollViewPView drawing
- void CCCachedScrollViewPView::OnDraw(CDC* pDC)
- {
- CCCachedScrollViewPDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDC->BitBlt(0,0,m_nBmpWidth,m_nBmpHeight,
- &m_MemDC,0,0,SRCCOPY);
- SetScrollSizes(MM_TEXT, CSize(m_nBmpWidth,m_nBmpHeight));
- CMainFrame *pParentFrame=(CMainFrame *)this->GetParentFrame();
- pParentFrame->RecalcLayout();
- ResizeParentToFit();
- }
- void CCCachedScrollViewPView::OnInitialUpdate()
- {
- //CScrollView::OnInitialUpdate();
- CSize sizeTotal;
- // TODO: calculate the total size of this view
- CDC *pDC = this->GetDC();
- m_MemDC.CreateCompatibleDC(pDC);
- m_bmpView.LoadBitmap(IDB_BITMAP1);
- // 这里IDB_BITMAP1是已经加入到工程资源中的BMP文件,当然也可以用文件的方式将图片从硬盘载入到内存中然后进行显示。
- m_MemDC.SelectObject(&m_bmpView);
- BITMAP Bitmap;
- m_bmpView.GetBitmap(&Bitmap);
- m_nBmpHeight = Bitmap.bmHeight;
- m_nBmpWidth = Bitmap.bmWidth;
- CSize size(m_nBmpWidth,m_nBmpHeight);
- SetScrollSizes(MM_TEXT,size);
- SetCacheSize(size);
- this->ReleaseDC(pDC);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCCachedScrollViewPView printing
- BOOL CCCachedScrollViewPView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CCCachedScrollViewPView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CCCachedScrollViewPView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCCachedScrollViewPView diagnostics
- #ifdef _DEBUG
- void CCCachedScrollViewPView::AssertValid() const
- {
- CScrollView::AssertValid();
- }
- void CCCachedScrollViewPView::Dump(CDumpContext& dc) const
- {
- CScrollView::Dump(dc);
- }
- CCCachedScrollViewPDoc* CCCachedScrollViewPView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCCachedScrollViewPDoc)));
- return (CCCachedScrollViewPDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CCCachedScrollViewPView message handlers