catching msie NewWindow2 event

mic aldo123 at onet.pl
Tue Jan 13 10:51:04 EST 2004


I'm trying to catch the MSIE NewWindow2 event using win32com interface. The
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 from
opening)

ie1 = DispatchWithEvents('InternetExplorer.Application', Events)
ie2 = DispatchWithEvents('InternetExplorer.Application', Events)
Events.Browser = ie2
ie1.Navigate('http://jaak.sav.net/test.html') #url to the html document that
opens its own window

I know that setting ppDisp value should work (at least I've seen it working
in C# code) but using it this way gives no results. What's more depending on
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