看看下面代碼的代碼
const WM_CAP_START = WM_USER;
const WM_CAP_STOP = WM_CAP_START +
const WM_CAP_DRIVER_CONNECT = WM_CAP_START +
const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START +
const WM_CAP_SAVEDIB = WM_CAP_START +
const WM_CAP_GRAB_FRAME = WM_CAP_START +
const WM_CAP_SEQUENCE = WM_CAP_START +
const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START +
const WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+
const WM_CAP_SET_OVERLAY =WM_CAP_START+
const WM_CAP_SET_PREVIEW =WM_CAP_START+
const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +
const WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +
const WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +
const WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +
const WM_CAP_SET_SCALE=WM_CAP_START+
const WM_CAP_SET_PREVIEWRATE=WM_CAP_START+
function capCreateCaptureWindowA(lpszWindowName : PCHAR; dwStyle : longint; x : integer;
y : integer;nWidth : integer;nHeight : integer;ParentWin : HWND;
nId : integer): HWND;STDCALL EXTERNAL
上面的代碼就是我們主要用到的一個函數和常量的定義
好了
新建一個窗口
begin
hWndC := capCreateCaptureWindowA(
hWndC := capCreateCaptureWindowA(
if hWndC <>
begin
SendMessage(hWndC
SendMessage(hWndC
SendMessage(hWndC
SendMessage(hWndC
SendMessage(hWndC
SendMessage(hWndC
SendMessage(hWndC
SendMessage(hWndC
end;
按F
if hWndC <>
SendMessage(hWndC
hWndC :=
end;
視屏截到了
再放三個按鈕到窗體上去
//保存BMP
if hWndC <>
SendMessage(hWndC
end;
//開始錄像
if hWndC <>
begin
SendMessage(hWndC
SendMessage(hWndC
end;
//停止錄像
if hWndC <>
SendMessage(hWndC
end;
再運行看看吧
程序運行效果
利用Delphi編程控制攝像頭(二)
From:http://tw.wingwit.com/Article/program/Delphi/201311/24710.html