Hi, this is my first posting. I'm trying to write a webbrowser using Synapse's Httpsend component and Turbopower's IpHtmlPanel but i cannot make it work. I searched the internet but to no avail. I can receive headers with the following code: procedure TForm1.GetHeaderButtonClick(Sender: TObject);
var HTTP : THTTPSend;
list : TStringlist;
Header : TStringlist;
begin
Header := TStringlist.Create;
HTTP := THTTPSend.Create;
list := TStringlist.Create;
Header.Add('Accept: text/html');
HTTP.Headers.AddStrings(Header);
try
if not HTTP.HTTPMethod('GET', Edit1.Text) then
begin
ShowMessage('Error' + sLineBreak + IntToStr(HTTP.ResultCode));
end
else
begin
Memo2.Lines.Clear;
Memo2.Lines.Append(IntToStr(HTTP.ResultCode) + ' ' + HTTP.ResultString);
Memo2.Lines.Append(HTTP.Headers.Text);
list.LoadFromStream(HTTP.Document);
Memo2.Lines.Append(list.Text);
end;
finally
HTTP.Free;
Header.Free;
list.Free;
end;
end;
And the following code produces raw HTML-code:
procedure TForm1.Button1Click(Sender: TObject);
var strings : TStringlist;
begin
with THTTPSend.Create do
begin
if HTTPMethod('GET', Edit1.Text) then
try
strings := TStringlist.Create;
strings.LoadFromStream(Document);
Memo1.Lines.AddStrings(strings);
strings.Free;
except
Application.MessageBox('Cannot display', 'Error', 0)
end;
Free;
end;
But the code below, using IpHtmlPanel, produces only a black window. Code:
procedure TForm1.Button1Click(Sender: TObject);
var s : TStringlist;
IpHtml : TIpHtml;
ms : TMemoryStream;
StrList : TStringList;
begin
with THTTPSend.Create do
begin
if HTTPMethod('GET', Edit1.Text) then
try
StrList := TStringList.Create;
//StrList.Text:= HTMLString; <- Something is wrong here!
ms := TMemoryStream.Create;
StrList.SaveToStream(ms);
ms.Position:= 0;
IpHtml := TIpHtml.Create;
IpHtml.LoadFromStream(ms);
IpHTMLPanel1.SetHtml(IpHtml);
ms.Free;
s := TStringlist.Create;
s.LoadFromStream(Document);
Memo1.Lines.AddStrings(s);
s.Free;
except
Application.MessageBox('Cannot display', 'Error', 0)
end;
Free;
end;
end;
I have realised that i have to use Lazarus IpFileDataProvider but i don't understand how to use it.
The code below is fetched from the Internet and shows an example of how to use it , but I get a compilation error trying to run it. TIpFormDataEntity is the culprit. As far as I understand, TIpFormDataEntity is used when making a POST to a web server. Where have I made mistakes in the codes ?Have anyone of you an example of a working webbrowser code using IPro's components.
Pardon my compilatory coding efforts.