Har fundet følgende program i Delphi Pages og ifølge program navnet lige
noget jeg kunne bruge
i mit program, men der er jo ingen forklaring med. Er der en der vel
forklare mig hvordan og hvorledes
jeg laver programmet.
I uses aksepteres de indtastede Id.... navne, men i type kan de ikke
findes ?
Er det fremmede komponenter der er brugt ?
Jeg går også ud fra det er selvskrevne procedure der bruges ?
Hvad for komponenter skal jeg ligge på formen ?
Er jeg fuldstendig på vildspor og apsålut ikke noget for en begynder vel
det også værer rart at vide.
En forklaring vel være dejligt.
M.V.H.
Henning.
Loading a JPEG from the internet
Note: Click Title to view in Edit Box for easier copying.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls,
Forms,
Dialogs, ExtCtrls, StdCtrls, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP,jpeg, ComCtrls,
IdAntiFreezeBase,
IdAntiFreeze;
type
TForm1 = class(TForm)
Client: TIdHTTP;
bGetImage: TButton;
ImageFromNet: TImage;
IdAntiFreeze1: TIdAntiFreeze;
ProgressBar: TProgressBar;
Label1: TLabel;
procedure bGetImageClick(Sender: TObject);
procedure ClientWorkBegin(Sender: TObject; AWorkMode:
TWorkMode;
const AWorkCountMax: Integer);
procedure ClientWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure ClientWorkEnd(Sender: TObject; AWorkMode:
TWorkMode);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.bGetImageClick(Sender: TObject);
var imagestream : TStringSTream;
jpg : TJPEGIMAGE;
begin
Label1.Caption := '';
ImageFromNet.Picture := nil;
imagestream := TStringStream.Create(''); {this will hold the
http
stream}
jpg := TJPEGIMAGE.Create;
try
Client.Get('
http://www.catlink.info/prodimages/DELPHI.jpg',imagestream);
{get the image}
imagestream.Seek(0,sofrombeginning); {go to the beginning of
the
stream}
jpg.LoadFromStream(imagestream); {this will load the stream
into
the JPEG object}
ImageFromNet.Picture.Assign(jpg); {Finally load the jpeg ..
:) }
except
ShowMessage('An error occured while loading the jpeg from
the
NET');
end;
jpg.Free;
imagestream.Free;
end;
procedure TForm1.ClientWorkBegin(Sender: TObject; AWorkMode:
TWorkMode;
const AWorkCountMax: Integer);
begin
ProgressBar.Max := AWorkCountMax;
ProgressBar.Position := 0;
end;
procedure TForm1.ClientWork(Sender: TObject; AWorkMode:
TWorkMode;
const AWorkCount: Integer);
begin
ProgressBar.Position := AWorkCount;
end;
procedure TForm1.ClientWorkEnd(Sender: TObject; AWorkMode:
TWorkMode);
begin
Label1.Caption := 'Image received !'
end;
end.