unit WebBrwsU;
interface
uses
	Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
	OleCtrls, isp3, ComCtrls, StdCtrls, ExtCtrls, Buttons;
type
	TWebMain = class(TForm)
		Panel1: TPanel;
		URLComboBox: TComboBox;
		StatusBar: TStatusBar;
		HTML: THTML;
		GoBtn: TBitBtn;
		StopBtn: TBitBtn;
		ReloadBtn: TBitBtn;
		SourceBtn: TBitBtn;
		procedure URLComboBoxClick(Sender: TObject);
		procedure URLComboBoxKeyPress(Sender: TObject; var Key: Char);
		procedure GoBtnClick(Sender: TObject);
		procedure StopBtnClick(Sender: TObject);
		procedure SourceBtnClick(Sender: TObject);
		procedure ReloadBtnClick(Sender: TObject);
		procedure HTMLDoRequestDoc(Sender: TObject; const URL: WideString;
			const Element: HTMLElement; const DocInput: DocInput;
			var EnableDefault: WordBool);
		procedure HTMLBeginRetrieval(Sender: TObject);
		procedure HTMLUpdateRetrieval(Sender: TObject);
		procedure HTMLEndRetrieval(Sender: TObject);
	private
		{ Private declarations }
	public
		{ Public declarations }
	end;
var
	WebMain: TWebMain;
implementation
{$R *.DFM}
procedure TWebMain.URLComboBoxClick(Sender: TObject);
begin
if URLComboBox.Text <> '' then
	HTML.RequestDoc(URLComboBox.Text);
end;
procedure TWebMain.URLComboBoxKeyPress(Sender: TObject; var Key: Char);
begin
	if Key =Char(VK_RETURN) then begin
		Key:=#0;
		if URLComboBox.Text ='' then
			exit;
			URLComboBoxClick(Sender);
			end;
end;
procedure TWebMain.GoBtnClick(Sender: TObject);
begin
	URLComboBoxClick(Self);
end;
procedure TWebMain.StopBtnClick(Sender: TObject);
begin
	HTML.Cancel(0);
	StatusBar.SimpleText:='Done';
end;
procedure TWebMain.SourceBtnClick(Sender: TObject);
begin
	HTML.ViewSource:= not HTML.ViewSource;
			if HTML.ViewSource then
				SourceBtn.Caption:='View Document'
			else
				SourceBtn.Caption:='View Source';
end;
procedure TWebMain.ReloadBtnClick(Sender: TObject);
begin
	URLComboBoxClick(Self);
end;
procedure TWebMain.HTMLDoRequestDoc(Sender: TObject; const URL: WideString;
		const Element: HTMLElement; const DocInput: DocInput;
		var EnableDefault: WordBool);
begin
	StatusBar.SimpleText:='Connecting to'+ URL +'...';
end;
procedure TWebMain.HTMLBeginRetrieval(Sender: TObject);
begin
	StatusBar.SimpleText:='Connected...';
	URLComboBox.Items.Insert(0,URLComboBox.Text);
end;
procedure TWebMain.HTMLUpdateRetrieval(Sender: TObject);
var
	Total	:integer;
	Done	:integer;
	Percent	:integer;
begin
		Total:=HTML.RetrieveBytesTotal;
		Done:=HTML.RetrieveBytesDone;
			if (Total=0) or (Done=0) then
				Percent:=0
			else
				Percent:=((Done*100) div Total);
				StatusBar.SimpleText:=Format(
				'Getting Document: %d%% of %dK',[Percent,Total div 1024]);
						
end;
procedure TWebMain.HTMLEndRetrieval(Sender: TObject);
begin
	StatusBar.SimpleText:='Done';
end;
end.