RSS订阅 | 匿名投稿
您的位置:网站首页 > 技巧 > 正文

DELPHI 打开网页的两种方法

作者:admin 来源:未知 日期:2010/1/30 15:56:16 人气: 标签:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj,ShellAPI;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation

{$R *.dfm}
//方法一 可调整窗口 uses里加入comobj
procedure TForm1.Button1Click(Sender: TObject);
procedure OpenInIe(URL:string);
var
Ie:Variant;
begin
Ie:=CreateOleObject('InternetExplorer.Application');
Ie.visible:=True;
Ie.left:=300; //与左边相隔距离
Ie.top:=200; //与顶部相隔距离
Ie.height:=400; //高度
Ie.width:=600; //宽度
Ie.menubar:=0; //隐藏菜单栏
Ie.toolbar:=0; //隐藏工具栏
Ie.addressbar:=0; //隐藏地址栏
//Ie.statubar:=0; //不可调整大小
Ie.resizable:=0;
Ie.navigate(URL);
end;
begin
OpenInIe('www.hi.baidu.com/yncg2046');
end;

//方法二 正常窗口打开 uses里加入shellapi
procedure TForm1.Button2Click(Sender: TObject);
begin
ShellExecute(Handle,'open','www.hi.baidu.com/yncg2046',nil,nil,SW_SHOWNORMAL)
end;

end.
读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: