在Delphi工程中打开网页问题

来源:百度知道 编辑:UC知道 时间:2024/06/18 18:44:51
我在Delphi工程中加入一个TWebBrowser用以显示网页,目前只能通过Button1Click使TWebBrowser显示相应的网页,我的问题是如何让TWebBrowser启动程序时就自动打开网页。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls;

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

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Webbrowser1.Navigate('www.bitmodel.cn/yy');
end;

end.
最好能再告诉我如何让固定窗体大小(使用者无法改变)及禁止TWebBrowser中显示滚动条。

procedure TForm1.FormActivate(Sender: TObject);
begin
Webbrowser1.Navigate('www.bitmodel.cn/yy');
end;

窗口固定大小在Form1的BorderStyle改成bsSingle

禁止滚动条有两个方法:
1、使用WebBrowser1的DocumentComplete事件
procedure TForm1.DocumentComplete(Sender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
begin
if Assigned(WebBrowser1.Document) then WebBrowser1.OleObject.Document.Body.Scroll:='no';
end;
2、如果可以修改嵌入的页面,在嵌入的页面中加上<body scroll=no>

在FormCreate事件中加载网页。