unit scanneruI;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Clipbrd, Math;
type
TForm1 =
class(TForm)
Panel1: TPanel;
Timer1: TTimer;
Image2: TImage;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
handle: THandle;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var
vdevice: boolean;
const
WM_CAP_DRIVER_CONNECT = WM_USER + 10;
WM_CAP_EDIT_COPY = WM_USER + 30;
WM_CAP_GRAB_FRAME_NOSTOP = WM_USER + 61;
//WM_CAP_SET_MCI_DEVICE = WM_USER + 66;
WM_CAP_DLG_VIDEOSOURCE = WM_USER + 42;
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.FormCreate(Sender: TObject);
begin
handle := capCreateCaptureWindow('
Video',ws_child+ws_visible, 0,
0, 640, 480, Panel1.handle, 0);
SendMessage(
handle, WM_CAP_DRIVER_CONNECT, 0, 0);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
clipboard.Clear;
SendMessage(
handle, WM_CAP_DLG_VIDEOSOURCE, 0, 0);
SendMessage(
handle, WM_CAP_GRAB_FRAME_NOSTOP, 1, 0);
SendMessage(
handle, WM_CAP_EDIT_COPY, 1, 0);
if vdevice
then
image1.Picture.LoadFromClipboardFormat(cf_BitMap,Clipboard.GetAsHandle(cf_Bitmap),0)
else
image2.Picture.LoadFromClipboardFormat(cf_BitMap,Clipboard.GetAsHandle(cf_Bitmap),0);
vdevice:=
not vdevice;
end;
end.