当Twebbrowser载入的页面时有的页面会自动关闭
页面关闭的代码一般为“window.close()”
那么,Twebbrowser就会被free,不知道这个问题该如何屏蔽???
原来这样解决的现在不灵了,郁闷中ing
Application.OnMessageprocedure TForm.ApplicationOnMessage(var Msg: tagMSG;
  var Handled: Boolean);
begin
  if (Msg.message = WM_CLOSE) and (Msg.hwnd = WebBrowser1.Handle) then
    Handled:=True
  else
    inherited;
end;望高手指点

解决方案 »

  1.   

    procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    var
      i : Integer;
    begin
      if (Msg.message = WM_CLOSE) then
      begin
        for i := 0 to Form1.ComponentCount -1 do
        begin
          if (Form1.Components[i] is TWebBrowser) and
             (Msg.hwnd = (Form1.Components[i] as TWebBrowser).Handle)
            then
            begin
              Handled := True;
              Break;
            end;
        end;
      end;
    end;
      

  2.   

    我试了,TWebBrowser可能没有被free,但是不可见了?怎么办??