为各个按钮添加点击事件,完整代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, VidGrab;
type
TForm1 = class(TForm)
VideoGrabber1: TVideoGrabber;
BtnPlay: TButton;
BtnPause: TButton;
BtnStop: TButton;
BtnClose: TButton;
procedure BtnPlayClick(Sender: TObject);
procedure BtnPauseClick(Sender: TObject);
procedure BtnStopClick(Sender: TObject);
procedure BtnCloseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//开启视屏
procedure TForm1.BtnPlayClick(Sender: TObject);
begin
videoGrabber1.StartPreview;
end;
//暂停或继续
procedure TForm1.BtnPauseClick(Sender: TObject);
begin
if BtnPause.Caption = '暂停' then
begin
btnPause.Caption := '继续';
VideoGrabber1.PausePreview;
end
else
begin
btnPause.Caption := '暂停';
VideoGrabber1.ResumePreview;
end;
end;
//停止视屏
procedure TForm1.BtnStopClick(Sender: TObject);
begin
videoGrabber1.StopPreview;
end;
//关闭窗体
procedure TForm1.BtnCloseClick(Sender: TObject);
begin
close;
end;
end.
以上代码在Delphi7+windows XP Sp3中测试通过
原文转发自:http://www.cnblogs.com/zhusd/archive/2010/06/22/1762531.html
这里有个下载地址:下载