⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 childview.cpp

📁 BCAM 1394 Driver
💻 CPP
字号:
//-----------------------------------------------------------------------------
//  (c) 2002 by Basler Vision Technologies
//  Section:  Vision Components
//  Project:  BCAM
//  $Header: ChildView.cpp, 2, 19.09.2002 15:32:52, Nebelung, H.$
//-----------------------------------------------------------------------------
/**
  \file     ChildView.cpp
  \brief    implementation of the CChildView class
*/

#include "stdafx.h"
#include "LiveViewMFC.h"
#include "ChildView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CChildView

CChildView::CChildView()
{
}

CChildView::~CChildView()
{
}


BEGIN_MESSAGE_MAP(CChildView,CWnd )
//{{AFX_MSG_MAP(CChildView)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CChildView message handlers

BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) 
{
  if (!CWnd::PreCreateWindow(cs))
    return FALSE;
  
  cs.dwExStyle |= WS_EX_CLIENTEDGE;
  cs.style &= ~WS_BORDER;
  cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, 
    ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
  
  return TRUE;
}

void CChildView::OnPaint() 
{
  CPaintDC dc(this); // device context for painting
  
  if((bool)m_ptrBitmap)
  {
    // Compute the viewport's coordinates in logical (image-) coordinates.
    CRect rect;
    GetClientRect(&rect);
    dc.DPtoLP(&rect);
    
    // Make sure to draw only those parts of the image which are visible in the viewport 
    CSize Size;
    m_ptrBitmap->GetSize(&Size);
    
    rect.IntersectRect(rect, CRect(0, 0, Size.cx, Size.cy));
    rect.InflateRect(1,1);
    
    // Draw the image
    //! \todo Handle the case that the graphics card uses a palette
    CDC dcMem;
    dcMem.CreateCompatibleDC(&dc);
    CBitmap* pBmpOld = dcMem.SelectObject(CBitmap::FromHandle((HBITMAP)m_ptrBitmap->GetBitmapHandle()));
    /*              if( m_dZoomScale < 1 )*/
    {
      dc.SetStretchBltMode(COLORONCOLOR);
    }                       
    dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dcMem, rect.left, rect.top, SRCCOPY);
    dcMem.SelectObject(pBmpOld);
  }
  
  
}


BOOL CChildView::OnEraseBkgnd(CDC* pDC) 
{
  //PrepareDC(pDC);  
  
  if(!m_ptrBitmap)
  {
    // Compute the viewport's coordinates in logical (image-) coordinates.
    RECT rect;
    GetClientRect(&rect);
    pDC->DPtoLP(&rect);
    pDC->FillRect(&rect, &CBrush(RGB(255,255,255)));
    
    return 0;
  }
  
  CSize Size;
  m_ptrBitmap->GetSize(&Size);
  
  int x = Size.cx + 1;
  int y = Size.cy + 1; 
  
  // Compute the viewport's coordinates in logical (image-) coordinates.
  RECT rect;
  GetClientRect(&rect);
  pDC->DPtoLP(&rect);
  
  // If the viewport is wider than the image draw a right margin
  if(rect.right > Size.cx)
  {
    RECT rectRight = rect;
    rectRight.left = x;
    rectRight.bottom = y;
    pDC->FillRect(&rectRight, &CBrush(RGB(255,255,255)));
  }
  
  // If the viewport is higher than the image draw a bottom margin
  if(rect.bottom > Size.cy)
  {
    RECT rectBottom = rect;
    rectBottom.top = y;
    pDC->FillRect(&rectBottom, &CBrush(RGB(255,255,255)));
  }
  
  // If there is an image draw a border between the margins and the image
  if(!m_ptrBitmap)
  {
    pDC->MoveTo(Size.cx, 0);
    pDC->LineTo(Size.cx, Size.cy);
    pDC->LineTo(0, Size.cy);
  }
  
  return true;
}

void CChildView::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
  CWnd ::OnActivate(nState, pWndOther, bMinimized);
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -