这样如何?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure MyWndProc(var Msg: TMsg; var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses vfw;
var
wndCap: HWND;
procedure TForm1.MyWndProc(var Msg: TMsg; var Handled: Boolean);
begin
if msg.hwnd = wndCap then
begin
if msg.message = WM_LBUTTONDOWN then caption := 'WM_LBUTTONDOWN';
if msg.message = WM_RBUTTONDOWN then caption := 'WM_RBUTTONDOWN';
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
wndCap := capCreateCaptureWindow('a', ws_visible or ws_child, 0, 0, 384, 288,
Panel1.Handle, 100);
capDriverConnect(wndCap, 0);
capPreview(wndCap, true);
capPreviewRate(wndCap, 66);
Application.OnMessage := MyWndProc;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
DestroyWindow(wndCap);
end;
end.