1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
const WM_CAP_DRIVER_CONNECT = WM_USER + 10; WM_CAP_DRIVER_DISCONNECT = WM_USER + 11; WM_CAP_EDIT_COPY = WM_USER + 30; WM_CAP_DLG_VIDEOSOURCE = WM_USER + 42; WM_CAP_SET_PREVIEW = WM_USER + 50; WM_CAP_SET_OVERLAY = WM_USER + 51; WM_CAP_SET_PREVIEWRATE = WM_USER + 52;
type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private public end;
var Form1: TForm1; vhandle: THandle;
implementation
{$R *.dfm}
function capCreateCaptureWindow(lpszWindowName: LPCSTR; dwStyle: DWORD; x, y, nWidth, nHeight: integer; hwndParent: HWND; nID: integer): HWND; stdcall; external 'AVICAP32.DLL' name 'capCreateCaptureWindowA';
procedure TForm1.Button1Click(Sender: TObject); begin if vhandle <= 0 then begin vhandle := capCreateCaptureWindow('Video',ws_child+ws_visible, 8, 8, 180, 240, Form1.Handle, 1); end; SendMessage(vhandle, WM_CAP_DRIVER_CONNECT, 0, 0); SendMessage(vhandle, WM_CAP_SET_PREVIEWRATE, 30, 0); SendMessage(vhandle, WM_CAP_SET_OVERLAY, 1, 0); SendMessage(vhandle, WM_CAP_SET_PREVIEW, 1, 0); end;
procedure TForm1.Button2Click(Sender: TObject); begin SendMessage(vhandle, WM_CAP_SET_PREVIEW, 0, 0); end;
procedure TForm1.Button3Click(Sender: TObject); begin SendMessage(vhandle, WM_CAP_DRIVER_DISCONNECT, 0, 0); end;
end. |