📄 hvviewerview.cpp
字号:
// HVViewerView.cpp : implementation of the CHVViewerView class
//
#include "stdafx.h"
#include "HVViewer.h"
#include "HVViewerDoc.h"
#include "HVViewerView.h"
#include "mainfrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHVViewerView
IMPLEMENT_DYNCREATE(CHVViewerView, CView)
BEGIN_MESSAGE_MAP(CHVViewerView, CView)
//{{AFX_MSG_MAP(CHVViewerView)
ON_WM_LBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CHVViewerView construction/destruction
CHVViewerView::CHVViewerView()
{
// TODO: add construction code here
}
CHVViewerView::~CHVViewerView()
{
}
BOOL CHVViewerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CHVViewerView drawing
void CHVViewerView::OnDraw(CDC* pDC)
{
CMainFrame *pFrame = NULL;
int nCxCoef = 1, nCyCoef = 1;
int nWidth = 0, nHeight = 0;
CHVViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pFrame = (CMainFrame *)AfxGetMainWnd();
if (pFrame && pFrame->m_pImageBuffer){
if ( ! pFrame->m_bSnapping){
if ((pFrame->m_hPalette) && (pFrame->m_pBmpInfo->bmiHeader.biBitCount == 8)) {
pFrame->m_hOldPal = ::SelectPalette(pDC->GetSafeHdc(), pFrame->m_hPalette, FALSE);
::RealizePalette(pDC->GetSafeHdc());
}
SetStretchBltMode(pDC->GetSafeHdc(), COLORONCOLOR);
if (pDC->IsPrinting()) {
nCxCoef = pDC->GetDeviceCaps(LOGPIXELSX);
nCyCoef = pDC->GetDeviceCaps(LOGPIXELSY);
nWidth = (int)((float)pFrame->m_pBmpInfo->bmiHeader.biWidth / 96 * nCxCoef);
nHeight = (int)((float)pFrame->m_pBmpInfo->bmiHeader.biHeight / 96 * nCyCoef);
StretchDIBits(pDC->GetSafeHdc(),
0,
0,
nWidth,
nHeight,
0,
0,
pFrame->m_pBmpInfo->bmiHeader.biWidth,
pFrame->m_pBmpInfo->bmiHeader.biHeight,
pFrame->m_pImageBuffer,
pFrame->m_pBmpInfo,
DIB_RGB_COLORS,
SRCCOPY
);
}
else{
StretchDIBits(pDC->GetSafeHdc(),
0,
0,
pFrame->m_pBmpInfo->bmiHeader.biWidth,
pFrame->m_pBmpInfo->bmiHeader.biHeight,
0,
0,
pFrame->m_pBmpInfo->bmiHeader.biWidth,
pFrame->m_pBmpInfo->bmiHeader.biHeight,
pFrame->m_pImageBuffer,
pFrame->m_pBmpInfo,
DIB_RGB_COLORS,
SRCCOPY
);
}
if ((pFrame->m_hOldPal) && (pFrame->m_pBmpInfo->bmiHeader.biBitCount == 8)) {
::SelectPalette(pDC->GetSafeHdc(), pFrame->m_hOldPal, FALSE);
::RealizePalette(pDC->GetSafeHdc());
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CHVViewerView printing
BOOL CHVViewerView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CHVViewerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CHVViewerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CHVViewerView diagnostics
#ifdef _DEBUG
void CHVViewerView::AssertValid() const
{
CView::AssertValid();
}
void CHVViewerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CHVViewerDoc* CHVViewerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHVViewerDoc)));
return (CHVViewerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CHVViewerView message handlers
void CHVViewerView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
{
// TODO: Add your specialized code here and/or call the base class
CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
ASSERT(pFrame);
CView::OnEndPrintPreview(pDC, pInfo, point, pView);
pFrame->SendMessage(WM_SIZE);
}
void CHVViewerView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
ASSERT(pFrame);
pFrame->SendMessage(WM_LBUTTONDOWN);
CView::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -