开发工具VS2008

实现目标:以最简单的方法实现视频的捕获、显示

1)建立空的解决方案

新建-》项目-》其他项目类型-》Visual stidio解决方案-》空白解决方案

名称:mySimapleCap

2)建立项目

新建-》项目-》Visual C++-》MFC-》MFC应用程序

名称:test1,添入解决方案

3)添加VFW头文件

test1Dlg.h中的#pragma once后添加#include <Vfw.h>

4)添加库引用语句

test1Dlg.cpp中添加#pragma comment(lib,"vfw32.lib")

5)添加窗口句柄变量

test1Dlg.h中public:后添加

HWND m_hWndVideo;

6)对话窗口初始化时BOOL Ctest1Dlg::OnInitDialog(),添加如下语句

m_hWndVideo = capCreateCaptureWindow(_T("My Cap"),WS_CHILD|WS_VISIBLE ,0,0,640,480,this->m_hWnd,(int)1);

 capDriverConnect(m_hWndVideo,   0);
 capPreviewRate( m_hWndVideo, 66 );
 capPreview( m_hWndVideo, TRUE );