14.10.2010, 19:08
|
|
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
Код:
unit Unit1;
interface
uses
ActiveX,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls;
type
TForm1 = class(TForm)
WebBrowser: TWebBrowser;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
CLSID_ShellUIHelper: TGUID = '{64AB4BB7-111E-11D1-8F79-00C04FC2FBE1}';
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
if WebBrowser.Document=nil then WebBrowser.Navigate('about:blank');
while WebBrowser.Document=nil do Application.ProcessMessages;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
url: OleVariant;
begin
url:='http://ya.ru/';
WebBrowser.Navigate2(url);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
ShellUIHelper: IShellUIHelper;
locationname: OleVariant;
locationurl: OleVariant;
res: HRESULT;
begin
res:=CoCreateInstance(CLSID_ShellUIHelper, nil, CLSCTX_INPROC_SERVER, IID_IShellUIHelper, ShellUIHelper);
if res=S_OK then
begin
locationname:=WebBrowser.LocationName;
locationurl:=WebBrowser.LocationURL;
ShellUIHelper.AddFavorite(locationurl, locationname);
end;
end;
end.
http://data.cod.ru/71360
__________________
Пишу программы за еду.
__________________
|