?? ccachedscrollviewpview.cpp
字號:
// 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是已經(jīng)加入到工程資源中的BMP文件,當(dāng)然也可以用文件的方式將圖片從硬盤載入到內(nèi)存中然后進(jìn)行顯示。
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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -