MMProgr.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:5k
- {========================================================================}
- {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
- {========================================================================}
- {= All Rights Reserved =}
- {========================================================================}
- {= D 01099 Dresden = Tel.: +0351-8012255 =}
- {= Loewenstr.7a = info@swiftsoft.de =}
- {========================================================================}
- {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
- {========================================================================}
- {= This code is for reference purposes only and may not be copied or =}
- {= distributed in any format electronic or otherwise except one copy =}
- {= for backup purposes. =}
- {= =}
- {= No Delphi Component Kit or Component individually or in a collection=}
- {= subclassed or otherwise from the code in this unit, or associated =}
- {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
- {= without express permission from SwiftSoft. =}
- {= =}
- {= For more licence informations please refer to the associated =}
- {= HelpFile. =}
- {========================================================================}
- {= $Date: 20.01.1998 - 18:00:00 $ =}
- {========================================================================}
- unit MMProgr;
- {$I COMPILER.INC}
- interface
- uses
- {$IFDEF WIN32}
- Windows,
- {$ELSE}
- WinTypes,
- WinProcs,
- {$ENDIF}
- Messages,
- SysUtils,
- Classes,
- Graphics,
- Controls,
- Forms,
- Dialogs,
- StdCtrls,
- ExtCtrls,
- MMObj,
- MMUtils,
- MMGauge;
- type
- {-- TMMProgressForm ---------------------------------------------------}
- TMMProgressForm = class(TForm)
- Panel1: TPanel;
- Bevel1: TBevel;
- Gauge: TMMGauge;
- btnCancel: TButton;
- end;
- TMMCloseEvent = procedure(Sender: TObject; Canceled: Boolean)of Object;
- {-- TMMProgress -------------------------------------------------------}
- TMMProgress = class(TMMNonVisualComponent)
- private
- FCaption : String;
- FForm : TMMProgressForm;
- FOnClose : TMMCloseEvent;
- FCanceled: Boolean;
- procedure CancelButtonClick(Sender: TObject);
- protected
- procedure Close; virtual;
- public
- constructor Create(AOwner: TComponent); override;
- procedure Execute;
- procedure SetProgress(aValue: integer);
- function Visible: Boolean;
- published
- property OnClose: TMMCloseEvent read FOnClose write FOnClose;
- property Caption: String read FCaption write FCaption;
- end;
- var
- MMProgressForm: TMMProgressForm;
- implementation
- {$R *.DFM}
- {== TMMProgress =========================================================}
- constructor TMMProgress.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FCaption := 'Progress...';
- FForm := nil;
- ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
- if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
- end;
- {-- TMMProgress ---------------------------------------------------------}
- procedure TMMProgress.Close;
- begin
- if (FForm <> nil) then
- begin
- FForm.Close;
- FForm.Free;
- FForm := nil;
- if assigned(FOnClose) then FOnClose(Self,FCanceled);
- end;
- end;
- {-- TMMProgress ---------------------------------------------------------}
- procedure TMMProgress.Execute;
- begin
- if (FForm = nil) then
- begin
- FCanceled := False;
- FForm := TMMProgressForm.Create(Application);
- FForm.Gauge.Caption := FCaption;
- FForm.btnCancel.OnClick := CancelButtonClick;
- FForm.Show;
- FForm.Update;
- end;
- end;
- {-- TMMProgress ---------------------------------------------------------}
- procedure TMMProgress.SetProgress(aValue: integer);
- begin
- if (FForm <> nil) then
- begin
- FForm.Gauge.Progress := aValue;
- if (aValue = 100) then Close;
- end;
- end;
- {-- TMMProgress ---------------------------------------------------------}
- function TMMProgress.Visible: Boolean;
- begin
- Result := (FForm <> nil) and FForm.Visible;
- end;
- {-- TMMProgress ---------------------------------------------------------}
- procedure TMMProgress.CancelButtonClick(Sender: TObject);
- begin
- FCanceled := True;
- Close;
- end;
- end.