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

📄 foreground.cpp

📁 opencv+mfc打开AVI文件
💻 CPP
字号:
// ForeGround.cpp : implementation file
//

#include "stdafx.h"
#include "OpenCVMFCF.h"
#include "ForeGround.h"

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

/////////////////////////////////////////////////////////////////////////////
// ForeGround dialog


ForeGround::ForeGround(CWnd* pParent /*=NULL*/)
	: CDialog(ForeGround::IDD, pParent)
{
	//{{AFX_DATA_INIT(ForeGround)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void ForeGround::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ForeGround)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ForeGround, CDialog)
	//{{AFX_MSG_MAP(ForeGround)
	ON_WM_PAINT()
	ON_WM_TIMER()
	ON_WM_SHOWWINDOW()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ForeGround message handlers

void ForeGround::PostNcDestroy() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CDialog::PostNcDestroy();
}

void ForeGround::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CDialog::OnPaint() for painting messages
}

void ForeGround::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CWnd   *pWnd=GetDlgItem(IDC_IMG);//IDC_PICTURE为控件ID   
    CDC		*cdc = GetDC();
    CRect   rect,myrect, myrectdown;   
    GetClientRect(&rect);  

	COpenCVMFCFDlg* dlg=(COpenCVMFCFDlg*)GetParent();
	HDC hdc = cdc->GetSafeHdc();
	if ( dlg->capture != 0 )
	{
		dlg->frame = cvQueryFrame( dlg->capture );
		if ( dlg->frame )
		{
			CvvImage img;
			img.CopyOf(dlg->frame);
			img.DrawToHDC(hdc,&rect);
		}
	}
	else
	{
		EndDialog(0);
		PostNcDestroy();
	}
	CDialog::OnTimer(nIDEvent);
}

void ForeGround::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	// TODO: Add your message handler code here
	
}

BOOL ForeGround::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetTimer(1,20,NULL); 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL ForeGround::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::DestroyWindow();
}

⌨️ 快捷键说明

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