{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% osCommerce Product Manager for Windows (oscpmwin). Copyright ©2003,2004,2005 by Mario A. Valdez-Ramirez. You can contact Mario A. Valdez-Ramirez by email at mario@mariovaldez.org or paper mail at Olmos 809, San Nicolas, NL. 66495, Mexico. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} unit progress; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls; CONST PDCallDebug = TRUE; type Topm_Form_Progress = class(TForm) Panel1: TPanel; opm_Label_ProgressMsg1: TLabel; opm_ProgressBar_Progress1: TProgressBar; opm_ProgressBar_Progress2: TProgressBar; opm_BitBtn_ProgressCancel: TBitBtn; opm_Label_ProgressMsg2: TLabel; procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); procedure opm_BitBtn_ProgressCancelClick(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private PDCanClose : BOOLEAN; PDIntProgress : LONGINT; PDWinList : POINTER; PDNowPlaying : BOOLEAN; public PDAllowCancel : BOOLEAN; PDCanceled : BOOLEAN; PDDoubleBars : BOOLEAN; PDMessage1 : STRING; PDMessage2 : STRING; PDIgnoreProgress : BOOLEAN; PROCEDURE PRopm_PDUpdate_Progress (Position, Bar : LONGINT; ProgressMessage : STRING); PROCEDURE PRopm_PDShow (AllowCancel, TwoBars : BOOLEAN); PROCEDURE PRopm_PDClose; end; var opm_Form_Progress: Topm_Form_Progress; implementation {$R *.dfm} uses gnugettext, balloons, attention, oscpmdata; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_Progress.FormCreate(Sender: TObject); begin PDCanClose := TRUE; PDAllowCancel := FALSE; PDCanceled := FALSE; PDDoubleBars := TRUE; PDMessage1 := ''; PDMessage2 := ''; PDIgnoreProgress := FALSE; PDIntProgress := 0; PDWinList := NIL; PDNowPlaying := FALSE; TranslateComponent (self); end; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_Progress.FormShow(Sender: TObject); begin PDCanClose := FALSE; PDNowPlaying := TRUE; PDCanceled := FALSE; IF (PDDoubleBars = TRUE) THEN BEGIN opm_ProgressBar_Progress1.Height := 16; opm_ProgressBar_Progress2.Visible := TRUE; END ELSE BEGIN opm_ProgressBar_Progress1.Height := 32; opm_ProgressBar_Progress2.Visible := FALSE; END; opm_ProgressBar_Progress1.Position := 0; opm_ProgressBar_Progress1.Min := 0; opm_ProgressBar_Progress1.Max := 100; opm_ProgressBar_Progress2.Position := 0; opm_ProgressBar_Progress2.Min := 0; opm_ProgressBar_Progress2.Max := 100; IF (PDAllowCancel = TRUE) THEN BEGIN opm_BitBtn_ProgressCancel.Visible := TRUE; opm_Form_Progress.Height := opm_BitBtn_ProgressCancel.Top + opm_BitBtn_ProgressCancel.Height + (opm_BitBtn_ProgressCancel.Height DIV 2); Screen.Cursor := opmC_Normal_Mouse; END ELSE BEGIN opm_BitBtn_ProgressCancel.Visible := FALSE; opm_Form_Progress.Height := opm_BitBtn_ProgressCancel.Top + (opm_BitBtn_ProgressCancel.Height DIV 2); Screen.Cursor := opmC_Wait_Mouse; END; opm_Label_ProgressMsg1.Caption := PDMessage1; opm_Label_ProgressMsg2.Caption := PDMessage2; PDIntProgress := 0; Application.ProcessMessages; end; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE Topm_Form_Progress.PRopm_PDUpdate_Progress (Position, Bar : LONGINT; ProgressMessage : STRING); BEGIN IF ((PDWinList <> NIL) AND (PDNowPlaying = TRUE)) THEN BEGIN IF (PDIgnoreProgress = FALSE) THEN BEGIN IF (PDDoubleBars = TRUE) THEN BEGIN IF (Bar = 1) THEN BEGIN IF (Position > opm_ProgressBar_Progress1.Max) THEN Position := opm_ProgressBar_Progress1.Max; opm_ProgressBar_Progress1.Position := Position; IF (ProgressMessage <> '') THEN opm_Label_ProgressMsg1.Caption := ProgressMessage; END ELSE BEGIN IF (Position > opm_ProgressBar_Progress2.Max) THEN Position := opm_ProgressBar_Progress2.Max; opm_ProgressBar_Progress2.Position := Position; IF (ProgressMessage <> '') THEN opm_Label_ProgressMsg2.Caption := ProgressMessage; END; END ELSE BEGIN IF (Position > opm_ProgressBar_Progress1.Max) THEN Position := opm_ProgressBar_Progress1.Max; opm_ProgressBar_Progress1.Position := Position; IF (ProgressMessage <> '') THEN opm_Label_ProgressMsg1.Caption := ProgressMessage; END; END ELSE BEGIN IF (PDIntProgress < 100) THEN INC (PDIntProgress, 10) ELSE PDIntProgress := 0; opm_ProgressBar_Progress1.Position := PDIntProgress; END; END ELSE IF (PDCallDebug = TRUE) THEN FNopm_Message ('Progress Coding Error UPDATE', mtWarning, [mbOk], opmG_UISilent); Application.ProcessMessages; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE Topm_Form_Progress.PRopm_PDClose; BEGIN IF ((PDWinList <> NIL) AND (PDNowPlaying = TRUE)) THEN BEGIN EnableTaskWindows (PDWinList); PDWinList := NIL; PDNowPlaying := FALSE; PDCanClose := TRUE; Close; END ELSE IF (PDCallDebug = TRUE) THEN FNopm_Message ('Progress Coding Error CLOSE', mtWarning, [mbOk], opmG_UISilent); END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE Topm_Form_Progress.PRopm_PDShow (AllowCancel, TwoBars : BOOLEAN); BEGIN IF ((PDWinList = NIL) AND (PDNowPlaying = FALSE)) THEN BEGIN PDWinList := DisableTaskWindows (Handle); PDAllowCancel := AllowCancel; PDDoubleBars := TwoBars; PDNowPlaying := TRUE; Show; END ELSE IF (PDCallDebug = TRUE) THEN FNopm_Message ('Progress Coding Error SHOW', mtWarning, [mbOk], opmG_UISilent); END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_Progress.opm_BitBtn_ProgressCancelClick (Sender: TObject); BEGIN PDCanceled := TRUE; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_Progress.FormClose(Sender: TObject; var Action: TCloseAction); BEGIN IF (PDCanClose = TRUE) THEN BEGIN Screen.Cursor := opmC_Normal_Mouse; Action := caHide; END ELSE Action := caNone; END; end.