iesniffer AddBrowser method
Return to Introduction  Previous page  Next page
Applies to
acIESniffer component.  

Declaration
function AddBrowser(Browser: IWebBrowser2): Boolean;  

Description
The AddBrowser method used to add some certain Browser window to the internal list of component, and want to hook all events from that certain Browser.  
 
The AddBrowser should be used only if Active property is False, so you don't want to detect the IE windows automatically and just want to receive events from some certain Browser (for example if you write the toolbar for Internet Explorer and want to receive events only from that browser inside the IE window below your toolbar).  
 
tip Don't worry about adding one Browser instance several times, function will add only ONE instance of browser, and will return False if the Browser already exists in the internal list of component. Also you don't need to remove browser from list, component will handle this automatically upon receiving OnWBQuit event (when IE window are closed).  
 
iiwarning Note that if you want to operate with only ONE browser, do not call Refresh method (which detects IE instances automatically and add all them to the internal list to hook their events), plus make sure that Active property is False (so Refresh method will not called automatically on timer-based schedule).  

Example
procedure TBandForm.NavigateFromBand(const URL: String);  
var  
  _Url, X: OleVariant;  
begin  
  acIESniffer1.AddBrowser(IE);  
  _Url := Url; X := 0;  
  IE.Navigate(Url, X, X, X, X);  
end;  
 
// another example how to add TWebBrowser to the internal list of IESniffer  
procedure TForm1.Button1Click(Sender: TObject);  
begin  
  IESniffer1.AddBrowser(WebBrowser1.ControlInterface);  
end;  

See also
Active and IEList properties;  
Refresh method;  
OnWindowLoad, OnWindowUnload, OnWBDownloadComplete and OnWBQuit events.