📄 waveletview.cpp
字号:
// waveletView.cpp : implementation of the CWaveletView class
//
#include "stdafx.h"
#include "wavelet.h"
#include "waveletDoc.h"
#include "waveletView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWaveletView
IMPLEMENT_DYNCREATE(CWaveletView, CScrollView)
BEGIN_MESSAGE_MAP(CWaveletView, CScrollView)
//{{AFX_MSG_MAP(CWaveletView)
// 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
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWaveletView construction/destruction
CWaveletView::CWaveletView()
{
// TODO: add construction code here
}
CWaveletView::~CWaveletView()
{
}
BOOL CWaveletView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CWaveletView drawing
void CWaveletView::OnDraw(CDC* pDC)
{
CWaveletDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if( pDoc->m_pTransfered == NULL)
return ;
unsigned char* pBitmap = pDoc -> m_pBitmap;
LPBITMAPINFO lpBitmapInfo = (LPBITMAPINFO)(pBitmap + 14);
unsigned char* pBitmapData = pDoc->m_pTransfered;
unsigned long biHeight = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biHeight;
unsigned long biWidth = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biWidth;
CRect rect;
GetClientRect(&rect);
long originx = 0;
long originy = 0;
if((unsigned long)(rect.Width()) > biWidth)
originx = (rect.Width() - biWidth)>>1;
if((unsigned long)(rect.Height()) > biHeight)
originy = (rect.Height() - biHeight)>>1;
SetDIBitsToDevice(pDC->m_hDC, originx, originy, biWidth, biHeight, 0, 0, 0, biHeight,
pBitmapData, lpBitmapInfo, DIB_RGB_COLORS);
return;
}
/////////////////////////////////////////////////////////////////////////////
// CWaveletView diagnostics
#ifdef _DEBUG
void CWaveletView::AssertValid() const
{
CScrollView::AssertValid();
}
void CWaveletView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CWaveletDoc* CWaveletView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWaveletDoc)));
return (CWaveletDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWaveletView message handlers
void CWaveletView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CWaveletDoc* pDoc = GetDocument();
unsigned char* pBitmap = pDoc -> m_pBitmap;
LPBITMAPINFO lpBitmapInfo = (LPBITMAPINFO)(pBitmap + 14);
int biHeight = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biHeight;
int biWidth = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biWidth;
CSize sizeTotal(biWidth, biHeight);
SetScrollSizes(MM_TEXT, sizeTotal);
CMainFrame* pAppFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
ASSERT_KINDOF(CMainFrame, pAppFrame);
CRect rc;
pAppFrame->GetClientRect(&rc);
if (rc.Width() >= sizeTotal.cx && rc.Height() >= sizeTotal.cy &&
(sizeTotal.cx>0 || sizeTotal.cy>0))
ResizeParentToFit(FALSE);
return;
}
void CWaveletView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
}
BOOL CWaveletView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -