catching msie NewWindow2 event

Roger Upole rupole at
Wed Jan 14 11:53:17 CET 2004

You have to return the out parameters.
Try adding
      return ppDisp,True
  to the bottom of OnNewWindow2.


"mic" <aldo123 at> wrote in message news:bu146d$66p$1 at
> I'm trying to catch the MSIE NewWindow2 event using win32com interface.
> code I use is basically something like below:
> from win32com.client import DispatchWithEvents
> class Events:
>     Browser = None
>     def OnNewWindow2(self, ppDisp, Cancel):
>         #catching the new window and trying to place it onto my own
>         ppDisp = Events.Browser
>         #Cancel = True - this doesn't work either (should prevent popup
> opening)
> ie1 = DispatchWithEvents('InternetExplorer.Application', Events)
> ie2 = DispatchWithEvents('InternetExplorer.Application', Events)
> Events.Browser = ie2
> ie1.Navigate('') #url to the html document
> opens its own window
> I know that setting ppDisp value should work (at least I've seen it
> in C# code) but using it this way gives no results. What's more depending
> the url I use the event is triggered or not (other standard events work
> okay). I've seen ctypes COM implementation demo that makes similiar things
> but it looks so much more complicated than win32com api. Hope somebody has
> some insight on that...
> Regards,
> Michal

More information about the Python-list mailing list