delphi7中以弹出窗口方式调用IE,如何修改窗口的标题等信息
procedure OpenInIE(aURL: string); var IE: Variant;begin IE := CreateOleObject('InternetExplorer.Application'); IE.Visible := true; //可见 IE.left := 0; IE.top := 0; IE.height := 600; //高度 IE.width := 600; //宽度 IE.menubar := 0; //取消菜单栏 IE.addressbar := 0; //取消地址栏 IE.toolbar := 0; //取消工具栏 IE.statusbar := 0; //取消状态栏 IE.resizable := 0; //不允许用户改变窗口大小 IE.Navigate(aURL);end;procedure TForm1.Button3Click(Sender: TObject);begin OpenInIE('http://www.baidu.com');end;unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, SHDocVw, OleServer, OleCtrls, ActiveX;type TInternetExplorerEx = class(TInternetExplorer) procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override; end; TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } IE: TInternetExplorerEx; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}{ TInternetExplorerEx }procedure TInternetExplorerEx.InvokeEvent(DispID: TDispID; var Params: TVariantArray);begin inherited; //调用任何事件之后都设置一下IE标题 SendMessage(Form1.IE.HWnd, WM_SETTEXT, 0, Integer(PChar('abc')));end;procedure TForm1.FormCreate(Sender: TObject);begin IE := TInternetExplorerEx.Create(nil); IE.ConnectKind := ckNewInstance; IE.Navigate('http://www.baidu.com'); IE.Visible := True;end;procedure TForm1.FormDestroy(Sender: TObject);begin try IE.Quit;//可能在程序结束前,IE窗体已经关闭了,这时候会报异常 except end; IE.Free;end;
[解决办法]