Entwickler-Ecke

Internet / Netzwerk - Get Problem


Muratxiv - Sa 02.09.06 18:53
Titel: Get Problem
Hallo,
ich programmiere noch nicht lange mit Delphi. Ich möchte von einer Wegbseite den Text in einem Label angezeigt bekommen. Leider zeigt Delphi folgenden Fehler: 'idhttp' does not contain a member named 'Get' at line 29(29:26) Das Programm sieht zurzeit so aus:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,ExtCtrls, idhttp;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := IdHTTP.Get('http://muratyiv.mu.ohost.de/beispiel.php');

end;

end.

Würde mich freuen, falls mir jemand helfen könnte :)


Marc. - Sa 02.09.06 18:58

Du brauchst zunächst eine Instanz der Klasse, die du erst erzeugen musst:

Delphi-Quelltext
1:
2:
3:
4:
5:
var idh: TIDHTTP;
begin
 idh := IDHTTP.TIdHTTP.Create(self);
 label1.Caption:= idh.Get('http://muratyiv.mu.ohost.de/beispiel.php');
end;



marc ;)


Muratxiv - Sa 02.09.06 19:01

Danke Marc. es klappt :D


jaenicke - Sa 02.09.06 19:11

Aber die erzeugte Instanz sollte auch mit idh.Free; wieder freigegeben werden nachdem sie benutzt wurde...