TIpHtmlPanel/ru
From Lazarus wiki
Jump to navigationJump to search
│
English (en) │
français (fr) │
polski (pl) │
русский (ru) │
Компонент TIpHtmlPanel предназначен для отображения HTML-страницы. Он является частью пакета Turbopower Internet Pro, обеспечивающий собственный доступ к HTML. Данный компонент доступен на вкладке IPro палитры компонентов.
property ALinkColor; property AllowTextSelect; property DataProvider; property FixedTypeface; property DefaultTypeFace; property DefaultFontSize; property FactBAParag; property FlagErrors; property LinkColor; property PrintSettings; property MarginHeight; property MarginWidth; property ShowHints; property TabOrder; property TabStop; property TextColor; property Visible; property VLinkColor; property WantTabs;
property OnControlClick; property OnControlClick2; property OnControlChange; property OnControlEditingDone; property OnControlCreate; property OnCurElementChange; property OnDocumentOpen; property OnHotChange; property OnHotClick;
Компонент TIpHtmlPanel получает содержимое HTML-страницы из TIpHTML:
In the example below is a TSynEdit used with a TSynHTMLSyn. The results are displayed as formatted HTML using a TIpHtmlPanel.
unit TipHtmlTest;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, IpHtml, SynHighlighterHTML, SynHighlighterAny,
SynEdit, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
const
htmfile = 'tiphtmltestdata.html';
type
TTipHtmlForm = class(TForm)
IpHtmlPanel1: TIpHtmlPanel;
Splitter1: TSplitter;
Memo1: TSynEdit;
SynHTMLSyn1: TSynHTMLSyn;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure MemoChange(Sender: TObject);
protected
public
procedure ShowText( const txt: string );
end;
var
TipHtmlForm: TTipHtmlForm;
implementation
{$R *.lfm}
procedure TTipHtmlForm.FormCreate(Sender: TObject);
begin
if FileExists( htmfile ) then
Memo1.Lines.LoadFromFile( htmfile )
else
Memo1.Lines.Text := '<html><head><title>tipmemo</title></head><body><h1>tipmemo</h1>See <b>' +htmfile + '</b></body></html>';
MemoChange( nil );
end;
procedure TTipHtmlForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
Memo1.Lines.SaveToFile( htmfile );
end;
procedure TTipHtmlForm.MemoChange(Sender: TObject);
begin
ShowText( Memo1.Lines.Text );
end;
procedure TTipHtmlForm.ShowText( const txt: string );
var
fs: TStringStream;
pHTML: TIpHtml;
begin
try
fs := TStringStream.Create( txt );
try
pHTML:=TIpHtml.Create; // Beware: Will be freed automatically by IpHtmlPanel1
pHTML.LoadFromStream(fs);
finally
fs.Free;
end;
IpHtmlPanel1.SetHtml( pHTML );
Caption := IpHtmlPanel1.Title;
except
on E: Exception do begin
MessageDlg( 'Error: '+E.Message, mtError, [mbCancel], 0 );
end;
end;
end;
См. также