动
动力汽车
Unregistered / Unconfirmed
GUEST, unregistred user!
创建了个线程,用来显示等待画面的gif动画,但是总是显示不出来,很是奇怪,请各位给个指点。
unit Unit3;
interface
uses
Classes, ExtCtrls;
type
TShowGifThread = class(TThread)
Timer1:TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
protected
procedure Execute;
override;
procedure ShowGif;
virtual;abstract;
public
constructor Create;
end;
TShowThread = class(TShowGifThread)
public
procedure ShowGif;override;
end;
implementation
{ TShowGifThread }
uses
Unit1,Unit2;
constructor TShowGifThread.Create;
begin
FreeOnTerminate := True;
inherited Create(false);
end;
procedure TShowThread.ShowGif;
begin
Form2 := TForm2.Create(nil);//运行到此处就跳过去了,不执行Form2.ShowModal了
Form2.ShowModal;
Form2.Free;
end;
procedure TShowGifThread.Timer1Timer(Sender: TObject);
begin
if Form1.TerminateFlag then
//Form1中用来确定线程结束的标志
do
Terminate;
end;
procedure TShowGifThread.Execute;
begin
{ Place thread code here }
Timer1.interval := 10000;
while 1 > 0do
begin
if Terminated then
begin
GifForm.FormExit;
Break;
end;
ShowGif;
end;
end;
end.
//显示Gif动画的Form2
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtrls, SHDocVw;
type
TForm2 = class(TForm)
WebBrowser1: TWebBrowser;
procedure FormShow(Sender: TObject);
procedure FormExit;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
procedure TForm2.FormShow(Sender: TObject);
begin
WebBrowser1.Navigate('d:/banner.gif');
end;
procedure TForm2.FormExit;
begin
// WebBrowser1.Quit;
end;
end.
unit Unit3;
interface
uses
Classes, ExtCtrls;
type
TShowGifThread = class(TThread)
Timer1:TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
protected
procedure Execute;
override;
procedure ShowGif;
virtual;abstract;
public
constructor Create;
end;
TShowThread = class(TShowGifThread)
public
procedure ShowGif;override;
end;
implementation
{ TShowGifThread }
uses
Unit1,Unit2;
constructor TShowGifThread.Create;
begin
FreeOnTerminate := True;
inherited Create(false);
end;
procedure TShowThread.ShowGif;
begin
Form2 := TForm2.Create(nil);//运行到此处就跳过去了,不执行Form2.ShowModal了
Form2.ShowModal;
Form2.Free;
end;
procedure TShowGifThread.Timer1Timer(Sender: TObject);
begin
if Form1.TerminateFlag then
//Form1中用来确定线程结束的标志
do
Terminate;
end;
procedure TShowGifThread.Execute;
begin
{ Place thread code here }
Timer1.interval := 10000;
while 1 > 0do
begin
if Terminated then
begin
GifForm.FormExit;
Break;
end;
ShowGif;
end;
end;
end.
//显示Gif动画的Form2
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtrls, SHDocVw;
type
TForm2 = class(TForm)
WebBrowser1: TWebBrowser;
procedure FormShow(Sender: TObject);
procedure FormExit;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
procedure TForm2.FormShow(Sender: TObject);
begin
WebBrowser1.Navigate('d:/banner.gif');
end;
procedure TForm2.FormExit;
begin
// WebBrowser1.Quit;
end;
end.