Hello!
I am playing with idea to build windows wxPython application around the
built-in InternetExplorer using wx.lib.iewin module.
The problem is that I can't figure out how to do some simple things like
preventing launching new windows. There is a EVT_NewWindow2 event exists
that supposed exactly for that purpose. I found several VB examples on the
subject, code looks like:
···
-----------------
Private Sub WebBrowser1_NewWindow2(ppDisp As Object,
Cancel As Boolean)
Dim frmWB As Form1
Set frmWB = New Form1
frmWB.WebBrowser1.RegisterAsBrowser = TRUE
Set ppDisp = frmWB.WebBrowser1.Object
frmWB.Visible = True
End Sub
-----------------
Now I build a wxPytnon equivalent for this code such as:
------------
... somethere
self.Bind( IE.EVT_NewWindow2, self.on_new_window, self )
...
def on_new_window( self, event ):
new_window = <create-new-IEHtmlWindow>
new_window.registerasbrowser = True
event.ppDisp = new_window
event.Skip()
-------------
Unfortunately this don't works. IE still launching their own windows. I
think one potential problem can be in
event.ppDisp = new_window
line. ppDisp should expect a reference DISPATCH interface to web-browser
object and I put a reference to IEHtmlWindow here. I am not shure does this
correct or don't. How to get dispatch interface out of IEHtmlWindow
instance?
I try with several properties that looks promising (like *application*,
*containter*, *document*), for example:
event.ppDisp = new_window.application
but only got an exceptions like:
"TypeError: Unable to convert value to expected type: (VT_EMPTY) for
property <Application>"
-------------
So my questions are:
1) Does lib.iewin mature enough to be usable in a real applications?
2) How to get DISPATCH interface of underlying browser object out of
IEHtmlWindow?
3) How to handle EVT_NewWindow2 correctly to control new windows launching?
4) Does anybody have a success with alternative ActiveX support solutions
(pywin, ctypes) using together with the wxPython?
Vladimir Ignatov