unit progress2; { [Progress] [1.1] Delphi 2005 March 2008 LICENSE The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at "http://www.mozilla.org/MPL/" Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is "[progress.pas / progress.dfm]". The Initial Developer of the Original Code is Martin Holmes (Victoria, BC, Canada, "http://www.mholmes.com/"). Copyright (C) 2007-2008 Martin Holmes and the University of Victoria Computing and Media Centre. The code was co-developed for university and personal projects, and rights are shared by Martin Holmes and the University of Victoria. All Rights Reserved. } { Written by Martin Holmes, beginning in 2007, as part of Markin 4. Subsequently used in UVic open-source projects, and released as open-source. This unit is the provides a simple popup progress bar window which can be updated through callbacks during long processes. Dependencies: TntUnicode libraries (Troy Wolbrink). } interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, TntForms, ComCtrls, TntComCtrls, StdCtrls, TntStdCtrls, Buttons, TntButtons; type TufrmProgress = class(TTntForm) ulbProgMessage: TTntLabel; upbProgress: TTntProgressBar; ubnCancel: TTntBitBtn; procedure ubnCancelClick(Sender: TObject); procedure TntFormShow(Sender: TObject); procedure TntFormCreate(Sender: TObject); private { Private declarations } public OperationCancelled: Boolean; procedure ShowProgress(CurrStage, TotalStages: integer; ProgCaption, StageMessage: WideString); { Public declarations } end; var ufrmProgress: TufrmProgress; implementation {$R *.DFM} { TufrmProgress } procedure TufrmProgress.ShowProgress(CurrStage, TotalStages: integer; ProgCaption, StageMessage: WideString); begin if TotalStages <> upbProgress.Max then upbProgress.Max := TotalStages; if CurrStage <> upbProgress.Position then upbProgress.Position := CurrStage; if ulbProgMessage.Caption <> StageMessage then ulbProgMessage.Caption := StageMessage; if Caption <> ProgCaption then Caption := ProgCaption; if not Visible then Show; Application.ProcessMessages; end; procedure TufrmProgress.TntFormCreate(Sender: TObject); begin Icon := Application.Icon; end; procedure TufrmProgress.TntFormShow(Sender: TObject); begin OperationCancelled := False; end; procedure TufrmProgress.ubnCancelClick(Sender: TObject); begin OperationCancelled := True; end; end.