unit Uwebcam;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, clipbrd;
type
TForm1 =
class(TForm)
Panel1: TPanel;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen}
public
{ Public-Deklarationen}
end;
var
Form1: TForm1;
//Zuerst brauchst du folgende Konstanten
const
WM_CAP_DRIVER_CONNECT = WM_USER + 10;
WM_CAP_EDIT_COPY = WM_USER + 30;
WM_CAP_SET_PREVIEW = WM_USER + 50;
WM_CAP_SET_OVERLAY = WM_USER + 51;
WM_CAP_SET_PREVIEWRATE = WM_USER + 52;
implementation
{$R *.dfm}
//Dann brauchst du noch das hier
function capCreateCaptureWindow(lpszWindowName: LPCSTR;
dwStyle: DWORD;
x, y,
nWidth,
nHeight: integer;
hwndParent: HWND;
nID: integer): HWND;
stdcall;
external '
AVICAP32.DLL'
name '
capCreateCaptureWindowA';
procedure TForm1.FormCreate(Sender: TObject);
//halt irgendne Prozedur, ich habs im Formcreate, damit ich gleich was seh ^^
var handle:THandle;
begin
handle := capCreateCaptureWindow('
Video',ws_child+ws_visible, 0,
0, 640, 480, Panel1.Handle, 1);
//Wie du siehst, brauchst du ein Panel in diesem Beispiel ;-)
SendMessage(
handle, WM_CAP_DRIVER_CONNECT, 0, 0);
SendMessage(
handle, WM_CAP_SET_PREVIEWRATE, 30, 0);
sendMessage(
handle, WM_CAP_SET_OVERLAY, 1, 0);
SendMessage(
handle, wm_cap_set_preview, 1, 0);
end;
function SaveWebcamPictureDIB(pFileName: PChar;WebcamHandle: THandle):Boolean;
const WM_CAP_FILE_SAVEDIB = WM_USER + 25;
begin
if IsWindow(WebcamHandle)
then
result := (SendMessage(WebcamHandle,WM_CAP_FILE_SAVEDIB,0,LPARAM(pFileName)) <> 0)
else
result := false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SaveWebcamPictureDIB(PChar('
C:\test.jpg'),
Handle);
end;
end.