0,0 → 1,86 |
// akMediaAdmin v. 1.1 |
// Copyright (c) 1999-2000 Anatoli Klassen |
|
unit WaitUnit; |
|
interface |
|
uses |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
StdCtrls, LoadUnit, ExtCtrls; |
|
type |
TWaitForm = class(TForm) |
AbortButton: TButton; |
WaitLabel: TLabel; |
Timer: TTimer; |
procedure AbortButtonClick(Sender: TObject); |
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
procedure TimerTimer(Sender: TObject); |
private |
FLoadThread : TLoadThread; |
FDone : boolean; |
public |
procedure Terminated(Sender : TObject); |
function Execute(Files : TStrings) : TStrings; |
procedure ShowState(Current, Total : longint); |
end; |
|
var |
WaitForm: TWaitForm; |
|
implementation |
|
{$R *.DFM} |
|
function TWaitForm.Execute(Files : TStrings) : TStrings; |
begin |
WaitLabel.Caption := 'Loading...'; |
AbortButton.Enabled := True; |
Application.BringToFront; |
|
FDone := False; |
|
FLoadThread := TLoadThread.Create(Files); |
FLoadThread.OnTerminate := WaitForm.Terminated; |
FLoadThread.FreeOnTerminate := False; |
|
ShowModal; |
|
Result := TStringList.Create; |
Result.AddStrings(FLoadThread.Result); |
|
FLoadThread.Free; |
end; |
|
procedure TWaitForm.AbortButtonClick(Sender: TObject); |
begin |
WaitLabel.Caption := 'Aborting...'; |
AbortButton.Enabled := False; |
|
FLoadThread.Terminate; |
end; |
|
procedure TWaitForm.Terminated; |
begin |
FDone := True; |
Close; |
end; |
|
procedure TWaitForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
begin |
CanClose := FDone; |
end; |
|
procedure TWaitForm.ShowState(Current, Total : longint); |
begin |
WaitLabel.Caption := Format('Load %d of %d', [Current, Total]); |
end; |
|
procedure TWaitForm.TimerTimer(Sender: TObject); |
begin |
// just to produce an event at end of loading - elsewise the form will be |
// displayed unlimited time :( |
end; |
|
end. |