请试一下下面例程。另外,这个例程退出时有错误发生,请教大家是什么原因。[?]
unit Unit13f;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, VrControls, VrThreads, dspack, OleServer;
type
TBounceThread=class(TThread)
private
FDSVideoWindow: TDSVideoWindow;
procedure WriteDSVideoWindow;
protected
procedure Execute;
override;
public
constructor Create(Suspended: Boolean;
DSVideoWindow: TDSVideoWindow);
property DSVideoWindow: TDSVideoWindow read FDSVideoWindow;
end;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
FilterGraph1: TDSFilterGraph2;
DWin: TDSVideoWindow;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
TimeStr: String;
WriteThread: TBounceThread;
implementation
{$R *.DFM}
procedure TBounceThread.WriteDSVideoWindow;
begin
with FDSVideoWindowdo
begin
Canvas.Font.Color:=clYellow;
Canvas.Font.Size:=12;
Canvas.TextOut(500,10,TimeStr);
end;
end;
procedure TBounceThread.Execute;
begin
while not Terminateddo
begin
Synchronize(WriteDSVideoWindow);
end;
end;
constructor TBounceThread.Create(Suspended: Boolean;
DSVideoWindow: TDSVideoWindow);
begin
inherited Create(Suspended);
FDSVideoWindow:=DSVideoWindow;
FreeOnTerminate:=True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WriteThread:=TBounceThread.Create(False, DWin);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
FilterGraph1.ClearGraph;
FilterGraph1.FilterGraph2.RenderFile(StringToOleStr(OpenDialog1.FileName),nil);
FilterGraph1.QueryInterfaces;
FilterGraph1.MediaControl.Run;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
TimeStr:=DateTimeToStr(Now);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
WriteThread.Suspend;
WriteThread.Free;
end;
end.