procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if Key = Chr(vk_Return)
then
WebBrowser1.Navigate(Edit1.Text);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if CheckBox1.Checked
then
WebBrowser1.Refresh;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
WebBrowser1.GoBack;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
WebBrowser1.GoForward;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
WebBrowser1.Stop;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
WebBrowser1.Refresh;
end;
procedure TForm1.FormResize(Sender: TObject);
var
r: TRect;
const
SB_GETRECT = WM_USER + 10;
begin
Edit1.Width := Form1.Width-68;
Statusbar1.Perform(SB_GETRECT, 0, Integer(@R));
ProgressBar1.Parent := Statusbar1;
ProgressBar1.SetBounds(10, r.Top+2, 102, r.Bottom - r.Top-4);
with Statusbar1
do
begin
Panels[1].Width := Width-125;
Panels[0].Width := 125;
Refresh;
end;
end;
procedure TForm1.WebBrowser1ProgressChange(ASender: TObject; Progress,
ProgressMax: Integer);
var
Position: Integer;
begin
try
if ProgressMax <> 0
then
begin
ProgressBar1.Enabled := true;
Position := (Progress * 100)
div ProgressMax;
ProgressBar1.Position := Position;
end;
except
end;
end;
procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject;
const pDisp: IDispatch;
var URL: OleVariant);
begin
ProgressBar1.Position := 0;
ProgressBar1.Enabled := false;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Webbrowser1.GoHome;
FormResize(
nil);
Bitbtn1.Enabled := false;
Bitbtn2.Enabled := false;
Timer2.Enabled := false;
end;
procedure TForm1.WebBrowser1StatusTextChange(ASender: TObject;
const Text: WideString);
begin
StatusBar1.Panels[1].Text := Text;
end;
procedure TForm1.Schliessen1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.WebBrowser1CommandStateChange(ASender: TObject;
Command: Integer; Enable: WordBool);
begin
case Command
of
CSC_NAVIGATEBACK: Bitbtn1.Enabled := Enable;
CSC_NAVIGATEFORWARD: Bitbtn2.Enabled := Enable;
end;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
Webbrowser1.GoHome;
end;
procedure TForm1.BitBtn6Click(Sender: TObject);
begin
WebBrowser1.GoSearch;
end;
procedure TForm1.BitBtn7Click(Sender: TObject);
begin
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
end;
procedure TForm1.BitBtn8Click(Sender: TObject);
begin
WebBrowser1.Navigate('
http://www.teklab.de/chat');
end;
procedure TForm1.BitBtn9Click(Sender: TObject);
begin
if LinkManager = 1
then begin
PageControl2.Visible := false;
LinkManager := 0;
end
else begin
PageControl2.Visible := true;
LinkManager := 1;
end;
end;
procedure TForm1.Seiteeinrichten1Click(Sender: TObject);
begin
WebBrowser1.ExecWB(OLECMDID_PAGESETUP, OLECMDEXECOPT_PROMPTUSER);
end;
procedure TForm1.Drucken1Click(Sender: TObject);
begin
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
end;
procedure TForm1.Druckvorschau1Click(Sender: TObject);
begin
WebBrowser1.ExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_PROMPTUSER);
end;
procedure TForm1.Einstellungen1Click(Sender: TObject);
begin
WebBrowser1.ExecWB(OLECMDID_PROPERTIES, OLECMDEXECOPT_PROMPTUSER);
end;
procedure TForm1.WebBrowser1NewWindow2(ASender: TObject;
var ppDisp: IDispatch;
var Cancel: WordBool);
var
TabSheet: TTabSheet;
Web: TWebbrowser;
begin
if Timer2.Enabled = false
then Timer2.Enabled := true;
if PopupBlocker < 2
then begin
TabSheet := TTabSheet.Create(Form1.PageControl1);
with TabSheet
do
begin
PageControl := Form1.PageControl1;
end;
Web := TWebbrowser.CreateParented(TabSheet.Handle);
TabSheet.InsertControl(Web);
TWinControl(Web).align := alClient;
ppDisp := Web.DefaultDispatch;
Web.OnNewWindow2 := Webbrowser1NewWindow2;
Web.OnCommandStateChange := Webbrowser1CommandStateChange;
web.OnDocumentComplete := Webbrowser1DocumentComplete;
Web.OnProgressChange := Webbrowser1ProgressChange;
Web.OnstatusTextChange := Webbrowser1StatusTextChange;
Pagecontrol1.Pages[pagecontrol1.PageCount - 1].caption := WebBrowser1.LocationName;
PageControl1.ActivePage:=PageControl1.Pages[pagecontrol1.PageCount - 1];
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
PopupBlocker := PopupBlocker+1;
if PopupBlocker = 20
then begin
PopupBlocker := 0;
Timer2.Enabled := false;
end;
end;