Ja jeg har et program som henter en fil ned fra nettede når man trykker på download knappen... den bruger idhttp...
i kan lige se koden til mig program her:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Gauges, IEDownload, INIFiles, XPMan,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
RadioGroup1: TRadioGroup;
IEDownload1: TIEDownload;
Gauge1: TGauge;
Edit1: TEdit;
Label1: TLabel;
Button2: TButton;
XPManifest1: TXPManifest;
Button3: TButton;
Button1: TButton;
IdHTTP1: TIdHTTP;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
I, T, L: Integer;
MyINI: TINIFile;
PathToINIFile: String;
begin
IEDownload1.Go('http://storstodder.dk/mulbo/md.ini','C:\\md.sys');
PathToINIFile := 'C:\\md.sys';
T := 15;
L := 5;
MyINI := TINIFile.Create(PathToINIFile);
for I := 1 to MyINI.ReadInteger('mulbo_software', 'antal', 0) do
begin
with TRadioButton.Create(RadioGroup1) do
begin
Parent := RadioGroup1;
Left := L;
Top := T;
Caption := MyINI.ReadString('mulbo_software', 'nr' + IntToStr(I) + '_tekst', ' ');
end;
T := T + 24;
end;
MyINI.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
I, T, L: Integer;
MyINI: TINIFile;
PathToINIFile: String;
begin
PathToINIFile := 'C:\\md.sys';
T := 15;
L := 5;
MyINI := TINIFile.Create(PathToINIFile);
for I := 1 to MyINI.ReadInteger('mulbo_software', 'antal', 0) do
begin
with TRadioButton.Create(RadioGroup1) do
begin
Parent := RadioGroup1;
Left := L;
Top := T;
Caption := MyINI.ReadString('mulbo_software', 'nr' + IntToStr(I) + '_tekst', ' ');
end;
T := T + 24;
end;
MyINI.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
DeleteFile('C:\\md.sys');
IEDownload1.Go('http://storstodder.dk/mulbo/md.ini','C:\\md.sys');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
I, X : integer;
Url, Filnavn, Filtype, PathToINIFile : String;
MyINI: TINIFile;
FStrm : TFileStream;
begin
PathToINIFile := 'C:\\md.sys';
MyINI := TINIFile.Create(PathToINIFile);
for I := 0 to RadioGroup1.ComponentCount -1 do
begin
if TRadioButton(RadioGroup1.Components[I]).Checked then
begin
X := I + 1;
Url := MyINI.ReadString('mulbo_software', 'nr' + IntToStr(X) + '_link', ' ');
Filnavn := MyINI.ReadString('mulbo_software', 'nr' + IntToStr(X) + '_filnavn', ' ');
Filtype := MyINI.ReadString('mulbo_software', 'nr' + IntToStr(X) + '_filtype', ' ');
FStrm := TFileStream.Create(edit1.text + filnavn + '.' + Filtype, fmCreate);
Try
IdHttp1.Get(url,Fstrm);
Finally
Fstrm.Free;
end;
end;
end;
MyINI.Free;
end;
procedure TForm1.IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
Gauge1.MaxValue := AworkCountMax;
end;
procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
Gauge1.Progress := AWorkCount;
end;
end.
Problemet er at når jeg så trykker på download så fryser programmet indtil den er færdig at downloade... og min gauge opdateres kun et par få gange....