我顶一下哈,在网上找到一段代码,但是不知道怎么使用,只是一个构造函数而已啊。。。。
#include <QLibrary>
#include <QMessageBox>
#include <windows.h>
const static int WM_CAP_START=WM_USER;
const static int WM_CAP_STOP = WM_CAP_START + 68;
const static int WM_CAP_DRIVER_CONNECT=WM_CAP_START+10;
const static int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const static int WM_CAP_SAVEDIB = WM_CAP_START + 25;
const static int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const static int WM_CAP_SEQUENCE = WM_CAP_START + 62;
const static int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
const static int WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63;
const static int WM_CAP_SET_OVERLAY =WM_CAP_START+ 51 ;
const static int WM_CAP_SET_PREVIEW =WM_CAP_START+ 50 ;
const static int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6;
const static int WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2;
const static int WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3;
const static int WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5;
const static int WM_CAP_SET_SCALE=WM_CAP_START+ 53;
const static int WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52;
CamViewer::CamViewer(QWidget *parent)
: QWidget(parent)
{
resize(400,300);
QLibrary mylib("avicap32");
if(mylib.load()){
// QMessageBox::information(this,tr("info"),tr("load dll OK!"));
typedef HWND(* capCreateFunc)(char *lpszWindowName,long int swStyle,
int x,int y,int nWidth,int nHeight,HWND parentWin,int nID);
capCreateFunc capCreate=(capCreateFunc)mylib.resolve("capCreateCaptureWindowA");
if(capCreate){
HWND h=capCreate("my own capture window",WS_CHILD|WS_VISIBLE,0,0,width(),height(),winId(),0);
if(h){
SendMessage(h,WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
SendMessage(h,WM_CAP_SET_CALLBACK_ERROR,0,0);
SendMessage(h,WM_CAP_SET_CALLBACK_STATUSA,0,0);
SendMessage(h,WM_CAP_DRIVER_CONNECT,0,0);
SendMessage(h,WM_CAP_SET_SCALE,1,0);
SendMessage(h,WM_CAP_SET_PREVIEWRATE,66,0);
SendMessage(h,WM_CAP_SET_OVERLAY,1,0);
SendMessage(h,WM_CAP_SET_PREVIEW,1,0);
}
}
}
}