unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, mshtml, ExtCtrls, ComCtrls,
WinSkinData;
type
TForm1 = class(TForm)
SkinData1: TSkinData;
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
CheckBox1: TCheckBox;
Panel1: TPanel;
StatusBar1: TStatusBar;
WebBrowser1: TWebBrowser;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure WebBrowser1StatusTextChange(Sender: TObject;
const Text: WideString);
procedure WebBrowser1TitleChange(Sender: TObject;
const Text: WideString);
procedure WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
s:IHTMLdocument2;
begin
if checkbox1.Checked then
begin
s:=webbrowser1.document as IHTMLdocument2;
s.cookie :=memo1.Text ; //αÔìCookie
webbrowser1.Navigate(edit1.Text);
end
else
webbrowser1.Navigate(edit1.Text);
end;
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
var
s:IHTMLdocument2;
begin
if not checkbox1.Checked then
begin
s:=webbrowser1.document as IHTMLdocument2;
memo1.Text :=s.cookie ; //È¡µÃCookie
checkbox1.Enabled :=true;
end;
end;
procedure TForm1.WebBrowser1StatusTextChange(Sender: TObject;
const Text: WideString);
begin
statusbar1.Panels[1].Text :=text; //״̬ÌõÄÚÈÝ
end;
procedure TForm1.WebBrowser1TitleChange(Sender: TObject;
const Text: WideString);
begin
form1.Caption :=text+' ¡ª KendyBrowser'; //±êÌâ
end;
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
edit1.Text :=url; //µØÖ·À¸
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
s:IHTMLdocument2;
begin
if key=#13 then
begin
if checkbox1.Checked then
begin
s:=webbrowser1.document as IHTMLdocument2;
s.cookie :=memo1.Text ;
webbrowser1.Navigate(edit1.Text);
end
else
webbrowser1.Navigate(edit1.Text);
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if memo1.ReadOnly then
memo1.ReadOnly :=false
else
memo1.ReadOnly :=true;
end;
end.