unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, lclintf,
SynMemo, IpHtml, Ipfilebroker, lNetComponents, lhttp, lNet;
type
{ TForm1 }
TForm1 = class(TForm)
IpFileDataProvider1: TIpFileDataProvider;
IpHtmlPanel1: TIpHtmlPanel;
IPS1: TLTCPComponent;
IPSHTTP1: TLHTTPClientComponent;
SynMemo1: TSynMemo;
procedure FormShow(Sender: TObject);
procedure IpHtmlPanel1Click(Sender: TObject);
procedure IPS1Connect(aSocket: TLSocket);
procedure IPS1Disconnect(aSocket: TLSocket);
procedure IPSHTTP1Disconnect(aSocket: TLSocket);
procedure IPSHTTP1DoneInput(ASocket: TLHTTPClientSocket);
procedure IPSHTTP1Error(const msg: string; aSocket: TLSocket);
function IPSHTTP1Input(ASocket: TLHTTPClientSocket; ABuffer: pchar;
ASize: integer): integer;
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure HTMLStringToHtmlPanel(const HTMLString:String; var HTMLPanel:TIpHtmlPanel);
var
html:TIpHtml;
ms:TMemoryStream;
StrList:TStringList;
begin
StrList:=TStringList.Create;
StrList.Text:=HTMLString;
ms:=TMemoryStream.Create;
StrList.SaveToStream(ms);
ms.Position:=0; // Von entscheidender Bedeutung, sonst geht es nicht(Vielleicht ein BUG in der LCL bzw. von TStream bzw. von TStringList.
html:=TIpHtml.Create;
html.LoadFromStream(ms);
HTMLPanel.SetHtml(
html);
ms.Free; StrList.Free;
end;
{ TForm1 }
procedure TForm1.Formshow(Sender: TObject);
var Port : integer;
ServerIP : String;
Verbindungsaufbau : boolean;
begin
ServerIP := '192.168.178.100';
Port := 80;
Verbindungsaufbau := IPS1.Connect(ServerIP,Port);
if not Verbindungsaufbau then Close;
IPSHTTP1.Host:= ServerIP;
IPSHTTP1.Connect('192.168.178.100', 80);
// if IPSHTTP1.Connect then caption:= 'ich Seh den IPS' else Caption:= 'wo ist der IPS?';
end;
procedure TForm1.IpHtmlPanel1Click(Sender: TObject);
begin
IPSHTTP1.SendRequest;
end;
procedure TForm1.IPS1Connect(aSocket: TLSocket);
begin
Synmemo1.Lines.LoadFromFile('ips.htm');
// HTMLStringToHtmlPanel(SynMemo1.Lines.Text,IpHtmlPanel1);
end;
procedure TForm1.IPS1Disconnect(aSocket: TLSocket);
begin
IPS1.Disconnect(True);
end;
procedure TForm1.IPSHTTP1Disconnect(aSocket: TLSocket);
begin
IPSHTTP1.Disconnect(True);
IPS1Disconnect(aSocket);
end;
procedure TForm1.IPSHTTP1DoneInput(ASocket: TLHTTPClientSocket);
begin
Caption:= 'ich Bin es nicht :D :P';
end;
procedure TForm1.IPSHTTP1Error(const msg: string; aSocket: TLSocket);
begin
Caption:= msg; // Fehlermeldung wird ausgelöst.
end;
function TForm1.IPSHTTP1Input(ASocket: TLHTTPClientSocket; ABuffer: pchar;
ASize: integer): integer;
begin
Caption:= 'Aber ich Bin es nicht :D :P';
end;
end.