Avatar of hidrau
hidrau
Flag for Brazil

asked on 

detect if a oleobject windows isn't valid by handle

Hello,

I have this function where I open my internet explorer with a url. I need to detect if my internet explorer was closed and then allow my function create a new call, if it is not closed, I just send the new url to it. How can I check this once I have the handle kept?

function OpenIE(url: string; ie: IWebBrowser2): IWebBrowser2;
var

  Flags, TargetFrameName, PostData, Headers: OleVariant;
begin
  if Not Assigned(ie) then
  Begin
    // Uses ComObj + SHDocVw_TLB
    ie := CreateOleObject('InternetExplorer.Application') as IWebBrowser2;
    //  SetParent(ie.HWND, form1.Handle);
    ie.Left := (Screen.Width - 750) div 2;
    ie.Top := (Screen.Height - 560) div 2;


    ie.Width := 750;
    ie.Height := 560;
    ie.MenuBar := false;
    ie.AddressBar := false;
    ie.Resizable := True;
    ie.StatusBar := false;
    ie.ToolBar := 0;

    ie.Navigate2(Url,Flags,TargetFrameName,PostData,Headers);
    ie.Visible := true;
  End Else
  Begin
    ie.Navigate2(Url,Flags,TargetFrameName,PostData,Headers);
  End;

  result := ie;
//  http://codeverge.com/embarcadero.delphi.win32/opening-an-application-inside-delphi/1049698
end;

Open in new window


Thanks
Alex
Delphi

Avatar of undefined
Last Comment
hidrau

8/22/2022 - Mon