Einzelnen Beitrag anzeigen

Spirit

Registriert seit: 21. Jun 2005
5 Beiträge
 
Delphi 2005 Personal
 
#5

Re: Frage zu WM_CAP_FILE_SAVEDIB

  Alt 21. Jun 2005, 23:30
So, es klappt. Vielen Dank nochmal!

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, XPMan;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    XPManifest1: TXPManifest;
    Button6: TButton;
    Image1: TImage;
    procedure Button6Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    Handle : HWND;
    FCapWnd: HWnd;

  end;

var
  Form1: TForm1;
  ghCapWnd: THandle;
  gCapSingleImageFileName : string;

const
  WM_CAP_DRIVER_CONNECT = WM_USER + 10;
  WM_CAP_DRIVER_DISCONNECT = WM_USER + 11;
  WM_CAP_EDIT_COPY = WM_USER + 30;
  WM_CAP_SET_OVERLAY = WM_USER + 51;
  WM_CAP_SET_PREVIEWRATE = WM_USER + 52;
  WM_CAP_DLG_VIDEOFORMAT = WM_USER + 41;
  WM_CAP_DLG_VIDEOSOURCE = WM_USER + 42;
  WM_CAP_FILE_SAVEDIB = WM_USER + 25;
  WM_CAP_DLG_VIDEODISPLAY = WM_USER + 43;
  WM_CAP_FILE_SET_CAPTURE_FILE = WM_USER + 44;
  WM_CAP_GRAB_FRAME = WM_USER + 60;

implementation

{$R *.dfm}

function capCreateCaptureWindow(lpszWindowName: PChar; dwStyle,x,y,nWidth,nHeight: Integer;
  hWndParent: HWND; nID: Integer): HWND; stdcall; external 'avicap32.dllname 'capCreateCaptureWindowA';

function AVICapSM(hwnd: HWND; m: UINT; w: WPARAM; l: LPARAM): DWORD;
begin
  if IsWindow(hwnd) then
    Result := SendMessage(hwnd,m,w,l)
  else
    Result := 0;
end;

function capFileSaveDIB(hwnd: HWND; szName: LPCSTR): BOOL;
begin
  Result := AVICapSM(hwnd, WM_CAP_FILE_SAVEDIB, 0, LPARAM(szName)) <> 0;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  SendMessage(handle,WM_CAP_DLG_VIDEOFORMAT,1,0);
end;


procedure TForm1.Button4Click(Sender: TObject);
var FileName: String;
begin
  capFileSaveDIB(handle, PChar('test.bmp'));
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  SendMessage(handle,WM_CAP_DLG_VIDEOSOURCE,1,0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Handle := capCreateCaptureWindow('Video1',WS_VISIBLE + WS_CHILD,0,0,160,
    120,Panel1.Handle,1);
  if Handle = 0 then begin
    Exit;
  end;
  if SendMessage(Handle,WM_CAP_DRIVER_CONNECT,0,0) = 0 then begin
    DestroyWindow(Handle);
    Handle := 0;
    Exit;
  end;
  SendMessage(handle, WM_CAP_DRIVER_CONNECT,0,0);
  SendMessage(handle, WM_CAP_SET_PREVIEWRATE,30,0);
  sendMessage(handle, WM_CAP_SET_OVERLAY,1,0);
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
  SendMessage(handle, WM_CAP_DLG_VIDEODISPLAY,0,0); //Funktioniert nicht.
end;

end.
  Mit Zitat antworten Zitat