const
WM_CAP_START = WM_USER;
WM_CAP_STOP = WM_CAP_START + 68;
WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
WM_CAP_EDIT_COPY = WM_CAP_START + 30;
WM_CAP_DLG_VIDEOSOURCE = (WM_CAP_START+ 42);
function capCreateCaptureWindowA(lpszWindowName : PCHAR;
dwStyle : longint;
x : integer;
y : integer;
nWidth : integer;
nHeight : integer;
ParentWin : HWND;
nId : integer): HWND;
STDCALL EXTERNAL 'AVICAP32.DLL';
procedure TForm1.BClick(Sender: TObject);
begin
if B.Caption = 'Start' then
begin
hWndC := capCreateCaptureWindowA('My Own Capture Window',
WS_CHILD or WS_VISIBLE ,
0,
0,
352,
288,
Form1.Handle,
0);
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
B.Caption := 'Stop';
Timer1.Enabled := True;
end;
end else
begin
B.Caption := 'Start';
Timer1.Enabled := False;
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var s : string;
begin
if (hWndC <> 0) and (SendMessage(hWndC, WM_CAP_GRAB_FRAME, 0, 0) = 1) and
(SendMessage(hWndC, WM_CAP_EDIT_COPY, 0, 0) = 1) and (Clipboard.HasFormat(CF_BITMAP)) then
begin
s := TimeToStr(Time);
s[3] := '.';
s[6] := '.';
s := DateToStr(Date) + ' - ' + s + '.jpg';
BMP.Assign(Clipboard);
JPG.Assign(BMP);
JPG.Compress;
// JPG.SaveToFile(SavePath + s);
end;
end;