~ubuntu-branches/ubuntu/lucid/nsis/lucid

« back to all changes in this revision

Viewing changes to Contrib/VPatch/Source/GUI/ProgressForm.pas

  • Committer: Bazaar Package Importer
  • Author(s): Paul Wise
  • Date: 2008-09-01 07:20:44 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080901072044-mjev9xfej6i2d63t
Tags: 2.37-3
Add nsDialogs stack corruption fix from nsis 2.38

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
unit ProgressForm;
2
 
 
3
 
interface
4
 
 
5
 
uses
6
 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
 
  Dialogs, StdCtrls, ComCtrls, ExtCtrls, Math;
8
 
 
9
 
type
10
 
  TfrmProg = class(TForm)
11
 
    prgFile: TProgressBar;
12
 
    lblFile: TLabel;
13
 
    lblNewFile: TLabel;
14
 
    prgNewFile: TProgressBar;
15
 
    lblTotal: TLabel;
16
 
    prgAll: TProgressBar;
17
 
    lblStatus: TLabel;
18
 
    shpFull: TShape;
19
 
    shpLeft: TShape;
20
 
    lblSize: TLabel;
21
 
    procedure GetStatusProc(S: PChar; Point, Total,
22
 
      CurrentSavings: Integer); stdcall;
23
 
    procedure FormCreate(Sender: TObject);
24
 
  private
25
 
    { Private declarations }
26
 
  public
27
 
    { Public declarations }
28
 
    FilePos,FileRange,AllPos,AllRange: Byte;
29
 
    CTotal: Integer;
30
 
    t2: TDateTime;
31
 
  end;
32
 
 
33
 
var
34
 
  frmProg: TfrmProg;
35
 
 
36
 
implementation
37
 
 
38
 
{$R *.dfm}
39
 
 
40
 
procedure TfrmProg.GetStatusProc(S: PChar; Point, Total, CurrentSavings: Integer); stdcall;
41
 
var
42
 
  a,b: Integer;
43
 
  j: Single;
44
 
begin
45
 
  if Length(S)>0 then
46
 
    lblStatus.Caption:=S;
47
 
  if (Total<0) then begin
48
 
    Total:=CTotal;
49
 
    if (Now-t2)*24*3600*10<8 then Exit; //update only every 800 milliseconds
50
 
  end;
51
 
  if (Total>=0) then CTotal:=Total;
52
 
  if (Total>=0) and (Point>=0) then begin
53
 
    a:=(Point*100) div Total;
54
 
    prgFile.Position:=a;
55
 
    b:=FilePos+(a*FileRange) div 100;
56
 
    prgNewFile.Position:=b;
57
 
    prgAll.Position:=AllPos+(b*AllRange) div 100;
58
 
  end;
59
 
  if (CurrentSavings>=0) and (Total>=0) then begin
60
 
    j:=(Total-CurrentSavings)*shpFull.Width/Total;
61
 
    shpLeft.Width:=Max(Round(j),3);
62
 
    lblSize.Caption:=IntToStr(Total-CurrentSavings)+' of '+IntToStr(Total)+' ('+IntToStr(CurrentSavings*100 div Total)+'%)';
63
 
  end;
64
 
  Refresh;
65
 
  t2:=Now;
66
 
end;
67
 
 
68
 
procedure TfrmProg.FormCreate(Sender: TObject);
69
 
begin
70
 
  FilePos:=0; FileRange:=100; AllPos:=0; AllRange:=100; CTotal:=-1;
71
 
  t2:=0;
72
 
end;
73
 
 
74
 
end.