unit ProgressFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, jpeg;
type
IProgress = interface
['{7AE77698-5497-44CD-8925-A33077147FD4}']
end;
TProgressForm = class(TForm)
lblmsg: TLabel;
imgWait: TImage;
end;
TMyProgress = class(TInterfacedObject, IProgress)
private
FProgressForm: TProgressForm;
FWindowList: Pointer;
public
constructor Create(AMsg: string);
destructor Destroy; override;
end;
function ShowProgress(AMsg: string): IProgress;
var
ProgressForm: TProgressForm;
implementation
{$R *.dfm}
function ShowProgress(AMsg: string): IProgress;
begin
Result := TMyProgress.Create(AMsg);
end;
var
arrWnds: array of HWnd;
procedure DisableThreadWindows(Window: HWnd; Data: Longint); stdcall;
begin
SetLength(arrWnds, Length(arrWnds) + 1);
arrWnds[Length(arrWnds) -1] := Window;
EnableWindow(Window, False);
end;
procedure EnableThreadWindows;
var
I: Integer;
begin
for I := 0 to Length(arrWnds) - 1 do
EnableWindow(arrWnds[I], True);
SetLength(arrWnds, 0);
end;
{ TMyProgress }
constructor TMyProgress.Create(AMsg: string);
begin
EnumThreadWindows(GetCurrentThreadID, @DisableThreadWindows, 0);
FProgressForm := TProgressForm.Create(nil);
FProgressForm.lblmsg.Caption := AMsg;
FProgressForm.lblmsg.Refresh;
FProgressForm.imgWait.Refresh;
FProgressForm.Show;
end;
destructor TMyProgress.Destroy;
begin
EnableThreadWindows;
FreeAndNil(FProgressForm);
EnableTaskWindows(FWindowList);
inherited;
end;
end.
浙公网安备 33010602011771号