procedure ApplicationMessage(var Msg: TMsg; var Handled: Boolean);
在form create时
Application.OnMessage := ApplicationMessage;
function tfrmhtmlbrowser.GetVisibleWebBrowser: TEmbeddedWb;
var
wb: Tembeddedwb;
tmp: TControl;
begin
tmp := pagecontrol.ActivePage.Controls[0];
wb := (tmp as Tembeddedwb);
Result := wb;
end; //End GetVisibleWebbrowser
procedure tfrmhtmlbrowser.ApplicationMessage(var Msg: TMsg; var Handled: Boolean);
var
wb: tembeddedwb;
begin
WB := GetVisibleWebBrowser; //取当前webbrowser控件
if (Msg.message = WM_CLOSE) and (Msg.hwnd = Wb.Handle) then
begin
closebtnclick(Self);//关闭webbrowser后,把相应的ttabsheet删除
end
else
inherited;
end; //end applicaitonmessage