IEHtmlWindow issue with floating Javascript

Hello,

I'm having an issue with IEHtmlWindow that I suspect is actually a
problem with the underlying Internet Explorer ActiveX control, but I'm
hoping someone more knowledgeable can help me. Floating Javascript
controls don't seem to be displayed when viewed within the
IEHtmlWindow. For example, the following code will load Google in a
new window. Note that google.com will typically pop up a list of
suggestions as you type a search term. This works in Internet
Explorer, but not in IEHtmlWindow. Any suggestions on how to fix this
would be very much appreciated.

Best regards,

Steve

import wx
import wx.lib.iewin

class HtmlFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, title="IEHtmlWindow Issue",
size=(800, 600))
        ie = wx.lib.iewin.IEHtmlWindow(self)
        ie.LoadUrl("http://google.com")

app = wx.PySimpleApp()
HtmlFrame().Show()
app.MainLoop()

Steve Willis wrote:

Hello,

I'm having an issue with IEHtmlWindow that I suspect is actually a
problem with the underlying Internet Explorer ActiveX control, but I'm
hoping someone more knowledgeable can help me. Floating Javascript
controls don't seem to be displayed when viewed within the
IEHtmlWindow. For example, the following code will load Google in a
new window. Note that google.com will typically pop up a list of
suggestions as you type a search term. This works in Internet
Explorer, but not in IEHtmlWindow. Any suggestions on how to fix this
would be very much appreciated.

You might try looking at the events being sent when the popup should be shown. There may be something that the container needs to do order to make it possible for, or allow, the popup to be shown.

···

--
Robin Dunn
Software Craftsman

Thanks for the advice! Is there a simple way to print all events
generated by an ActiveX control? I'm looking at the AddEventSync
function in wx.lib.activex, but it appears to require knowledge of the
names of events that could be fired.

Best regards,

Steve

···

On Aug 20, 12:33 pm, Robin Dunn <ro...@alldunn.com> wrote:

Steve Willis wrote:
> Hello,

> I'm having an issue with IEHtmlWindow that I suspect is actually a
> problem with the underlying Internet Explorer ActiveX control, but I'm
> hoping someone more knowledgeable can help me. Floating Javascript
> controls don't seem to be displayed when viewed within the
> IEHtmlWindow. For example, the following code will load Google in a
> new window. Note that google.com will typically pop up a list of
> suggestions as you type a search term. This works in Internet
> Explorer, but not in IEHtmlWindow. Any suggestions on how to fix this
> would be very much appreciated.

You might try looking at the events being sent when the popup should be
shown. There may be something that the container needs to do order to
make it possible for, or allow, the popup to be shown.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Steve Willis wrote:

···

On Aug 20, 12:33 pm, Robin Dunn <ro...@alldunn.com> wrote:

Steve Willis wrote:

Hello,
I'm having an issue with IEHtmlWindow that I suspect is actually a
problem with the underlying Internet Explorer ActiveX control, but I'm
hoping someone more knowledgeable can help me. Floating Javascript
controls don't seem to be displayed when viewed within the
IEHtmlWindow. For example, the following code will load Google in a
new window. Note that google.com will typically pop up a list of
suggestions as you type a search term. This works in Internet
Explorer, but not in IEHtmlWindow. Any suggestions on how to fix this
would be very much appreciated.

You might try looking at the events being sent when the popup should be
shown. There may be something that the container needs to do order to
make it possible for, or allow, the popup to be shown.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Thanks for the advice! Is there a simple way to print all events
generated by an ActiveX control? I'm looking at the AddEventSync
function in wx.lib.activex, but it appears to require knowledge of the
names of events that could be fired.

Search for IWebBrowser2 at MSDN.

--
Robin Dunn
Software Craftsman

I wrote the following program to observe which events are fired from
the ActiveX control while text is entered into the Google search bar.
Remember, my issue is not with Google in particular, but it is a good
example of a website with a floating autocomplete box that updates
itself as text is entered that works in Internet Explorer but not in
IEHtmlWindow. It appears that only the CommandStateChange event is
being fired while characters are entered into the search box. The MSDN
documentation suggests this has to do only with the availability of
buttons in the browser's navigation bar. I don't see an opportunity to
allow anything to happen that is being denied or vetoed elsewhere.

Thanks for the help. Any other thoughts would be greatly appreciated!

Steve

···

On Aug 20, 3:36 pm, Robin Dunn <ro...@alldunn.com> wrote:

Steve Willis wrote:
> On Aug 20, 12:33 pm, Robin Dunn <ro...@alldunn.com> wrote:
>> Steve Willis wrote:
>>> Hello,
>>> I'm having an issue with IEHtmlWindow that I suspect is actually a
>>> problem with the underlying Internet Explorer ActiveX control, but I'm
>>> hoping someone more knowledgeable can help me. Floating Javascript
>>> controls don't seem to be displayed when viewed within the
>>> IEHtmlWindow. For example, the following code will load Google in a
>>> new window. Note that google.com will typically pop up a list of
>>> suggestions as you type a search term. This works in Internet
>>> Explorer, but not in IEHtmlWindow. Any suggestions on how to fix this
>>> would be very much appreciated.
>> You might try looking at the events being sent when the popup should be
>> shown. There may be something that the container needs to do order to
>> make it possible for, or allow, the popup to be shown.

>> --
>> Robin Dunn
>> Software Craftsmanhttp://wxPython.org

> Thanks for the advice! Is there a simple way to print all events
> generated by an ActiveX control? I'm looking at the AddEventSync
> function in wx.lib.activex, but it appears to require knowledge of the
> names of events that could be fired.

Search for IWebBrowser2 at MSDN.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

#########################

import wx
import wx.lib.iewin

class HtmlFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, title="IEHtmlWindow Issue",
size=(800, 600))
        ie = wx.lib.iewin.IEHtmlWindow(self)
        ie.LoadUrl("http://google.com")
        ie.AddEventSink(self)

    # Events from the WebBrowser ActiveX object
    # WebBrowser object (Internet Explorer)

    def BeforeNavigate(*args):
        """Fires before navigation occurs in the given object (on
either a window or frameset element)."""
        print 'BeforeNavigate'

    def BeforeNavigate2(*args):
        """Fires before navigation occurs in the given object (on
either a window element or a frameset element)."""
        print 'BeforeNavigate2'

    def ClientToHostWindow(*args):
        """Fires to request that the client window size is converted
to the host window size."""
        print 'ClientToHostWindow'

    def CommandStateChange(*args):
        """Fires when the enabled state of a command changes."""
        print 'CommandStateChange'

    def DocumentComplete(*args):
        """Fires when a document is completely loaded and
initialized."""
        print 'DocumentComplete'

    def DownloadBegin(*args):
        """Fires when a navigation operation begins. """
        print 'DownloadBegin'

    def DownloadComplete(*args):
        """Fires when a navigation operation finishes, is halted, or
fails."""
        print 'DownloadComplete'

    def FileDownload(*args):
        """Fires to indicate that a file download is about to occur.
If a file download dialog box can be displayed, this event fires prior
to the appearance of the dialog box."""
        print 'FileDownload'

    def NavigateComplete(*args):
        """Fires after a navigation to a link is completed on either a
window element or a frameSet element. """
        print 'NavigateComplete'

    def NavigateComplete2(*args):
        """Fires after a navigation to a link is completed on a window
element or a frameSet element."""
        print 'NavigateComplete2'

    def NavigateError(*args):
        """Fires when an error occurs during navigation."""
        print 'NavigateError'

    def NewProcess(*args):
        """Creates a new process to handle the navigation."""
        print 'NewProcess'

    def NewWindow(*args):
        """Fires when a new window is to be created."""
        print 'NewWindow'

    def NewWindow2(*args):
        """Fires when a new window is to be created."""
        print 'NewWindow2'

    def NewWindow3(*args):
        """Raised when a new window is to be created. Extends
NewWindow2 with additional information about the new window."""
        print 'NewWindow3'

    def PrintTemplateInstantiation(*args):
        """Fires when a print template is instantiated."""
        print 'PrintTemplateInstantiation'

    def PrintTemplateTeardown(*args):
        """Fires when a print template is destroyed."""
        print 'PrintTemplateTeardown'

    def PrivacyImpactedStateChange(*args):
        """Fired when an event occurs that impacts privacy, or when a
user navigates away from a URL that has impacted privacy."""
        print 'PrivacyImpactedStateChange'

    def ProgressChange(*args):
        """Fires when the progress of a download operation is updated
on the object."""
        print 'ProgressChange'

    def RedirectXDomainBlocked(*args):
        """Fired when a cross-domain redirect request is blocked."""
        print 'RedirectXDomainBlocked'

    def SetPhishingFilterStatus(*args):
        """Fires to indicate the progress and status of Microsoft
Phishing Filter analysis of the current webpage."""
        print 'SetPhishingFilterStatus'

    def SetSecureLockIcon(*args):
        """Fires when there is a change in encryption level."""
        print 'SetSecureLockIcon'

    def StatusTextChange(*args):
        """Fires when the status bar text of the object has
changed."""
        print 'StatusTextChange'

    def ThirdPartyUrlBlocked(*args):
        """Fired when a third-party URL is blocked."""
        print 'ThirdPartyUrlBlocked'

    def TitleChange(*args):
        """Fires when the title of a document in the object becomes
available or changes."""
        print 'TitleChange'

    def UpdatePageStatus(*args):
        """Not implemented."""
        print 'UpdatePageStatus'

    def WindowClosing(*args):
        """Fires when the window of the object is about to be closed
by script."""
        print 'WindowClosing'

    def WindowSetHeight(*args):
        """Fires when the object changes its height."""
        print 'WindowSetHeight'

    def WindowSetLeft(*args):
        """Fires when the object changes its left position."""
        print 'WindowSetLeft'

    def WindowSetResizable(*args):
        """Fires to indicate whether the host window should allow
resizing of the object."""
        print 'WindowSetResizable'

    def WindowSetTop(*args):
        """Fires when the object changes its top position."""
        print 'WindowSetTop'

    def WindowSetWidth(*args):
        """Fires when the object changes its width."""
        print 'WindowSetWidth'

    def WindowStateChanged(*args):
        """Fires when the visibility state of a content window, such
as the browser window or a tab, changes."""
        print 'WindowStateChanged'

app = wx.PySimpleApp()
HtmlFrame().Show()
app.MainLoop()

Some additional information: this problem does not seem related to
Javascript itself. Note that in the above example, clicking the "More"
menu at the top of the google.com page correctly displays a floating
Javascript menu. The issue seems to be with key presses somehow.
Obviously, key press events are being received by the ActiveX control
(otherwise the text being typed into the search field would not show
up), but floating Javascript menus triggered by onChange text field
events aren't working.

This would seem to be a large problem for a number of sites on the
Internet that use floating elements of some sort in response to
typing, but I can't find anyone else who has experienced this. I would
appreciate anyone willing to run the program above and see if the
behavior is different on your system. I am using Windows XP with
Internet Explorer 8 within a VMWare virtual machine on a Mac. I'd be
interested to know if this is really just a problem with my own
environment.

Thanks!

Steve

···

On Aug 20, 6:46 pm, Steve Willis <st...@stevewillis.net> wrote:

On Aug 20, 3:36 pm, Robin Dunn <ro...@alldunn.com> wrote:

> Steve Willis wrote:
> > On Aug 20, 12:33 pm, Robin Dunn <ro...@alldunn.com> wrote:
> >> Steve Willis wrote:
> >>> Hello,
> >>> I'm having an issue with IEHtmlWindow that I suspect is actually a
> >>> problem with the underlying Internet Explorer ActiveX control, but I'm
> >>> hoping someone more knowledgeable can help me. Floating Javascript
> >>> controls don't seem to be displayed when viewed within the
> >>> IEHtmlWindow. For example, the following code will load Google in a
> >>> new window. Note that google.com will typically pop up a list of
> >>> suggestions as you type a search term. This works in Internet
> >>> Explorer, but not in IEHtmlWindow. Any suggestions on how to fix this
> >>> would be very much appreciated.
> >> You might try looking at the events being sent when the popup should be
> >> shown. There may be something that the container needs to do order to
> >> make it possible for, or allow, the popup to be shown.

> >> --
> >> Robin Dunn
> >> Software Craftsmanhttp://wxPython.org

> > Thanks for the advice! Is there a simple way to print all events
> > generated by an ActiveX control? I'm looking at the AddEventSync
> > function in wx.lib.activex, but it appears to require knowledge of the
> > names of events that could be fired.

> Search for IWebBrowser2 at MSDN.

> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org

I wrote the following program to observe which events are fired from
the ActiveX control while text is entered into the Google search bar.
Remember, my issue is not with Google in particular, but it is a good
example of a website with a floating autocomplete box that updates
itself as text is entered that works in Internet Explorer but not in
IEHtmlWindow. It appears that only the CommandStateChange event is
being fired while characters are entered into the search box. The MSDN
documentation suggests this has to do only with the availability of
buttons in the browser's navigation bar. I don't see an opportunity to
allow anything to happen that is being denied or vetoed elsewhere.

Thanks for the help. Any other thoughts would be greatly appreciated!

Steve

#########################

import wx
import wx.lib.iewin

class HtmlFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, title="IEHtmlWindow Issue",
size=(800, 600))
ie = wx.lib.iewin.IEHtmlWindow(self)
ie.LoadUrl("http://google.com")
ie.AddEventSink(self)

\# Events from the WebBrowser ActiveX object
\#http://msdn.microsoft.com/en-us/library/aa752085(VS.85).aspx

def BeforeNavigate\(\*args\):
    &quot;&quot;&quot;Fires before navigation occurs in the given object \(on

either a window or frameset element)."""
print 'BeforeNavigate'

def BeforeNavigate2\(\*args\):
    &quot;&quot;&quot;Fires before navigation occurs in the given object \(on

either a window element or a frameset element)."""
print 'BeforeNavigate2'

def ClientToHostWindow\(\*args\):
    &quot;&quot;&quot;Fires to request that the client window size is converted

to the host window size."""
print 'ClientToHostWindow'

def CommandStateChange\(\*args\):
    &quot;&quot;&quot;Fires when the enabled state of a command changes\.&quot;&quot;&quot;
    print &#39;CommandStateChange&#39;

def DocumentComplete\(\*args\):
    &quot;&quot;&quot;Fires when a document is completely loaded and

initialized."""
print 'DocumentComplete'

def DownloadBegin\(\*args\):
    &quot;&quot;&quot;Fires when a navigation operation begins\. &quot;&quot;&quot;
    print &#39;DownloadBegin&#39;

def DownloadComplete\(\*args\):
    &quot;&quot;&quot;Fires when a navigation operation finishes, is halted, or

fails."""
print 'DownloadComplete'

def FileDownload\(\*args\):
    &quot;&quot;&quot;Fires to indicate that a file download is about to occur\.

If a file download dialog box can be displayed, this event fires prior
to the appearance of the dialog box."""
print 'FileDownload'

def NavigateComplete\(\*args\):
    &quot;&quot;&quot;Fires after a navigation to a link is completed on either a

window element or a frameSet element. """
print 'NavigateComplete'

def NavigateComplete2\(\*args\):
    &quot;&quot;&quot;Fires after a navigation to a link is completed on a window

element or a frameSet element."""
print 'NavigateComplete2'

def NavigateError\(\*args\):
    &quot;&quot;&quot;Fires when an error occurs during navigation\.&quot;&quot;&quot;
    print &#39;NavigateError&#39;

def NewProcess\(\*args\):
    &quot;&quot;&quot;Creates a new process to handle the navigation\.&quot;&quot;&quot;
    print &#39;NewProcess&#39;

def NewWindow\(\*args\):
    &quot;&quot;&quot;Fires when a new window is to be created\.&quot;&quot;&quot;
    print &#39;NewWindow&#39;

def NewWindow2\(\*args\):
    &quot;&quot;&quot;Fires when a new window is to be created\.&quot;&quot;&quot;
    print &#39;NewWindow2&#39;

def NewWindow3\(\*args\):
    &quot;&quot;&quot;Raised when a new window is to be created\. Extends

NewWindow2 with additional information about the new window."""
print 'NewWindow3'

def PrintTemplateInstantiation\(\*args\):
    &quot;&quot;&quot;Fires when a print template is instantiated\.&quot;&quot;&quot;
    print &#39;PrintTemplateInstantiation&#39;

def PrintTemplateTeardown\(\*args\):
    &quot;&quot;&quot;Fires when a print template is destroyed\.&quot;&quot;&quot;
    print &#39;PrintTemplateTeardown&#39;

def PrivacyImpactedStateChange\(\*args\):
    &quot;&quot;&quot;Fired when an event occurs that impacts privacy, or when a

user navigates away from a URL that has impacted privacy."""
print 'PrivacyImpactedStateChange'

def ProgressChange\(\*args\):
    &quot;&quot;&quot;Fires when the progress of a download operation is updated

on the object."""
print 'ProgressChange'

def RedirectXDomainBlocked\(\*args\):
    &quot;&quot;&quot;Fired when a cross\-domain redirect request is blocked\.&quot;&quot;&quot;
    print &#39;RedirectXDomainBlocked&#39;

def SetPhishingFilterStatus\(\*args\):
    &quot;&quot;&quot;Fires to indicate the progress and status of Microsoft

Phishing Filter analysis of the current webpage."""
print 'SetPhishingFilterStatus'

def SetSecureLockIcon\(\*args\):
    &quot;&quot;&quot;Fires when there is a change in encryption level\.&quot;&quot;&quot;
    print &#39;SetSecureLockIcon&#39;

def StatusTextChange\(\*args\):
    &quot;&quot;&quot;Fires when the status bar text of the object has

changed."""
print 'StatusTextChange'

def ThirdPartyUrlBlocked\(\*args\):
    &quot;&quot;&quot;Fired when a third\-party URL is blocked\.&quot;&quot;&quot;
    print &#39;ThirdPartyUrlBlocked&#39;

def TitleChange\(\*args\):
    &quot;&quot;&quot;Fires when the title of a document in the object becomes

available or changes."""
print 'TitleChange'

def UpdatePageStatus\(\*args\):
    &quot;&quot;&quot;Not implemented\.&quot;&quot;&quot;
    print &#39;UpdatePageStatus&#39;

def WindowClosing\(\*args\):
    &quot;&quot;&quot;Fires when the window of the object is about to be closed

by script."""
print 'WindowClosing'

def WindowSetHeight\(\*args\):
    &quot;&quot;&quot;Fires when the object changes its height\.&quot;&quot;&quot;
    print &#39;WindowSetHeight&#39;

def WindowSetLeft\(\*args\):
    &quot;&quot;&quot;Fires when the object changes its left position\.&quot;&quot;&quot;
    print &#39;WindowSetLeft&#39;

def WindowSetResizable\(\*args\):
    &quot;&quot;&quot;Fires to indicate whether the host window should allow

resizing of the object."""
print 'WindowSetResizable'

def WindowSetTop\(\*args\):
    &quot;&quot;&quot;Fires when the object changes its top position\.&quot;&quot;&quot;
    print &#39;WindowSetTop&#39;

def WindowSetWidth\(\*args\):
    &quot;&quot;&quot;Fires when the object changes its width\.&quot;&quot;&quot;
    print &#39;WindowSetWidth&#39;

def WindowStateChanged\(\*args\):
    &quot;&quot;&quot;Fires when the visibility state of a content window, such

as the browser window or a tab, changes."""
print 'WindowStateChanged'

app = wx.PySimpleApp()
HtmlFrame().Show()
app.MainLoop()

Steve Willis wrote:

Some additional information: this problem does not seem related to
Javascript itself. Note that in the above example, clicking the "More"
menu at the top of the google.com page correctly displays a floating
Javascript menu. The issue seems to be with key presses somehow.
Obviously, key press events are being received by the ActiveX control
(otherwise the text being typed into the search field would not show
up), but floating Javascript menus triggered by onChange text field
events aren't working.

This would seem to be a large problem for a number of sites on the
Internet that use floating elements of some sort in response to
typing, but I can't find anyone else who has experienced this. I would
appreciate anyone willing to run the program above and see if the
behavior is different on your system. I am using Windows XP with
Internet Explorer 8 within a VMWare virtual machine on a Mac. I'd be
interested to know if this is really just a problem with my own
environment.

Take a look in the wx.lib.activex module at the MSWTranslateMessage method. This is called by the base class to allow the widget to deal with the raw messages before they are dispatched. In the activex class it is forwarding key-down messages through the IOleInPlaceActiveObject interface of the COM object. This was done so the IWebBrowser (or other ActiveX control that needs this) would be able to get the TAB key and handle doing tab-traversal through the elements on the page. I didn't really understand all the details of this and just copied and translated this from another source and it seemed to do what it was supposed to. Perhaps something else is needed here or something similar that needs to be done to handle the use case you are working on, but I have no idea what.

···

--
Robin Dunn
Software Craftsman

I grabbed the source for the wx.ib.activex module from SVN and rewrote
it to omit the binding to MSWTranslateMessage, but the result is the
same. I'm not sure this is a problem with key down events, because the
ActiveX control is obviously still receiving key presses somehow (the
text you type into the Google search box still shows up, but the
floating menu of suggestions does not). I'm still not sure if this is
even a problem with wxPython. If anyone more familiar with embedding
ActiveX controls with other languages (say, Visual Basic or C++) would
give it a try and see if the Google suggest feature still doesn't
work, I could eliminate wxPython as the source of the problem
altogether.

Thanks!

Steve

···

On Aug 21, 11:52 am, Robin Dunn <ro...@alldunn.com> wrote:

Steve Willis wrote:
> Some additional information: this problem does not seem related to
> Javascript itself. Note that in the above example, clicking the "More"
> menu at the top of the google.com page correctly displays a floating
> Javascript menu. The issue seems to be with key presses somehow.
> Obviously, key press events are being received by the ActiveX control
> (otherwise the text being typed into the search field would not show
> up), but floating Javascript menus triggered by onChange text field
> events aren't working.

> This would seem to be a large problem for a number of sites on the
> Internet that use floating elements of some sort in response to
> typing, but I can't find anyone else who has experienced this. I would
> appreciate anyone willing to run the program above and see if the
> behavior is different on your system. I am using Windows XP with
> Internet Explorer 8 within a VMWare virtual machine on a Mac. I'd be
> interested to know if this is really just a problem with my own
> environment.

Take a look in the wx.lib.activex module at the MSWTranslateMessage
method. This is called by the base class to allow the widget to deal
with the raw messages before they are dispatched. In the activex class
it is forwarding key-down messages through the IOleInPlaceActiveObject
interface of the COM object. This was done so the IWebBrowser (or other
ActiveX control that needs this) would be able to get the TAB key and
handle doing tab-traversal through the elements on the page. I didn't
really understand all the details of this and just copied and translated
this from another source and it seemed to do what it was supposed to.
Perhaps something else is needed here or something similar that needs to
be done to handle the use case you are working on, but I have no idea what.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

I located an example Visual Basic program online that makes use of
this ActiveX control, and it functions properly in that environment.
It appears that something wxPython related is preventing floating
Javascript elements on key presses. I'm investigating the possibility
that this isn't a key press issue per se, but perhaps a focus issue
with the control. I notice that clicking away from an Internet
Explorer window will also dismiss floating elements on a web page when
it loses focus.

Steve

···

On Aug 22, 8:54 am, Steve Willis <st...@stevewillis.net> wrote:

I grabbed the source for the wx.ib.activex module from SVN and rewrote
it to omit the binding to MSWTranslateMessage, but the result is the
same. I'm not sure this is a problem with key down events, because the
ActiveX control is obviously still receiving key presses somehow (the
text you type into the Google search box still shows up, but the
floating menu of suggestions does not). I'm still not sure if this is
even a problem with wxPython. If anyone more familiar with embedding
ActiveX controls with other languages (say, Visual Basic or C++) would
give it a try and see if the Google suggest feature still doesn't
work, I could eliminate wxPython as the source of the problem
altogether.

Thanks!

Steve

On Aug 21, 11:52 am, Robin Dunn <ro...@alldunn.com> wrote:

> Steve Willis wrote:
> > Some additional information: this problem does not seem related to
> > Javascript itself. Note that in the above example, clicking the "More"
> > menu at the top of the google.com page correctly displays a floating
> > Javascript menu. The issue seems to be with key presses somehow.
> > Obviously, key press events are being received by the ActiveX control
> > (otherwise the text being typed into the search field would not show
> > up), but floating Javascript menus triggered by onChange text field
> > events aren't working.

> > This would seem to be a large problem for a number of sites on the
> > Internet that use floating elements of some sort in response to
> > typing, but I can't find anyone else who has experienced this. I would
> > appreciate anyone willing to run the program above and see if the
> > behavior is different on your system. I am using Windows XP with
> > Internet Explorer 8 within a VMWare virtual machine on a Mac. I'd be
> > interested to know if this is really just a problem with my own
> > environment.

> Take a look in the wx.lib.activex module at the MSWTranslateMessage
> method. This is called by the base class to allow the widget to deal
> with the raw messages before they are dispatched. In the activex class
> it is forwarding key-down messages through the IOleInPlaceActiveObject
> interface of the COM object. This was done so the IWebBrowser (or other
> ActiveX control that needs this) would be able to get the TAB key and
> handle doing tab-traversal through the elements on the page. I didn't
> really understand all the details of this and just copied and translated
> this from another source and it seemed to do what it was supposed to.
> Perhaps something else is needed here or something similar that needs to
> be done to handle the use case you are working on, but I have no idea what.

> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org

Solved, with possible side effects. Someone smarter than I will need
to consider how the change I made might break other things.

Currently, wx.lib.activex MSWTranslateMessage method is handling the
translation of only the WM_KEYDOWN message to enable tab traversal. If
WM_KEYUP (value = 257) is also a condition for this if-statement, the
javascript behaves as expected. On a more general note, I'm not sure
why we're only catching certain events here. I figured this out by
removing the if-statement altogether and simply translating all
events, and didn't see any negative effects immediately. E.g., this
was my revised MSWTranslateMessage method in its entirety:

def MSWTranslateMessage(self, msg):
    res = self.ipao.TranslateAccelerator(msg)
    return res == hr.S_OK

Again, someone who has a better handle on how this all works should
look at the effects of the above.

Robin, thank you very much for your assistance and for pointing me in
the right direction!

Best regards,

Steve

···

On Aug 22, 10:05 am, Steve Willis <st...@stevewillis.net> wrote:

On Aug 22, 8:54 am, Steve Willis <st...@stevewillis.net> wrote:

> I grabbed the source for the wx.ib.activex module from SVN and rewrote
> it to omit the binding to MSWTranslateMessage, but the result is the
> same. I'm not sure this is a problem with key down events, because the
> ActiveX control is obviously still receiving key presses somehow (the
> text you type into the Google search box still shows up, but the
> floating menu of suggestions does not). I'm still not sure if this is
> even a problem with wxPython. If anyone more familiar with embedding
> ActiveX controls with other languages (say, Visual Basic or C++) would
> give it a try and see if the Google suggest feature still doesn't
> work, I could eliminate wxPython as the source of the problem
> altogether.

> Thanks!

> Steve

> On Aug 21, 11:52 am, Robin Dunn <ro...@alldunn.com> wrote:

> > Steve Willis wrote:
> > > Some additional information: this problem does not seem related to
> > > Javascript itself. Note that in the above example, clicking the "More"
> > > menu at the top of the google.com page correctly displays a floating
> > > Javascript menu. The issue seems to be with key presses somehow.
> > > Obviously, key press events are being received by the ActiveX control
> > > (otherwise the text being typed into the search field would not show
> > > up), but floating Javascript menus triggered by onChange text field
> > > events aren't working.

> > > This would seem to be a large problem for a number of sites on the
> > > Internet that use floating elements of some sort in response to
> > > typing, but I can't find anyone else who has experienced this. I would
> > > appreciate anyone willing to run the program above and see if the
> > > behavior is different on your system. I am using Windows XP with
> > > Internet Explorer 8 within a VMWare virtual machine on a Mac. I'd be
> > > interested to know if this is really just a problem with my own
> > > environment.

> > Take a look in the wx.lib.activex module at the MSWTranslateMessage
> > method. This is called by the base class to allow the widget to deal
> > with the raw messages before they are dispatched. In the activex class
> > it is forwarding key-down messages through the IOleInPlaceActiveObject
> > interface of the COM object. This was done so the IWebBrowser (or other
> > ActiveX control that needs this) would be able to get the TAB key and
> > handle doing tab-traversal through the elements on the page. I didn't
> > really understand all the details of this and just copied and translated
> > this from another source and it seemed to do what it was supposed to.
> > Perhaps something else is needed here or something similar that needs to
> > be done to handle the use case you are working on, but I have no idea what.

> > --
> > Robin Dunn
> > Software Craftsmanhttp://wxPython.org

I located an example Visual Basic program online that makes use of
this ActiveX control, and it functions properly in that environment.
It appears that something wxPython related is preventing floating
Javascript elements on key presses. I'm investigating the possibility
that this isn't a key press issue per se, but perhaps a focus issue
with the control. I notice that clicking away from an Internet
Explorer window will also dismiss floating elements on a web page when
it loses focus.

Steve

Steve Willis wrote:

Solved, with possible side effects. Someone smarter than I will need
to consider how the change I made might break other things.

Currently, wx.lib.activex MSWTranslateMessage method is handling the
translation of only the WM_KEYDOWN message to enable tab traversal. If
WM_KEYUP (value = 257) is also a condition for this if-statement, the
javascript behaves as expected. On a more general note, I'm not sure
why we're only catching certain events here. I figured this out by
removing the if-statement altogether and simply translating all
events, and didn't see any negative effects immediately. E.g., this
was my revised MSWTranslateMessage method in its entirety:

def MSWTranslateMessage(self, msg):
    res = self.ipao.TranslateAccelerator(msg)
    return res == hr.S_OK

Again, someone who has a better handle on how this all works should
look at the effects of the above.

I expect that the above is the right way to do it, although it should probably still give the base class version of the method a chance to run so wx can still deal with accelerators, etc. Like I said I just translated that code to Python from a C++ example I saw someplace, and I've always suspected it a little bit. Thanks for experimenting with this.

···

--
Robin Dunn
Software Craftsman

Yes, the above MSWTranslateMessage is ultimately what I used in a
custom IEHtmlWindow subclass, rather than the base activex class. I
would recommend it for inclusion in the official IEHtmlWindow class. I
also came across the C/C++ code you translated this from, and it
appears to be a workaround for a bug in wxWidgets that has since been
corrected, so I think it is safe to disable the accelerator key code
in any case.

For others who subclass IEHtmlWindow, this is also a good place to
disable certain functionality by filtering for Windows messages. For
example, in my application I don't want the Internet Explorer right-
click context menu to be available. I saw a number of methods for
dealing with this on the Internet, but all were workarounds (i.e.,
modifying Javascript on each page). In my MSWTranslateMessage method,
I filter the appropriate messages for right-clicks and simply don't
pass them to the underlying ActiveX control.

Thanks again for your help with this. It works perfectly now!

Steve

···

On Aug 24, 3:52 pm, Robin Dunn <ro...@alldunn.com> wrote:

Steve Willis wrote:
> Solved, with possible side effects. Someone smarter than I will need
> to consider how the change I made might break other things.

> Currently, wx.lib.activex MSWTranslateMessage method is handling the
> translation of only the WM_KEYDOWN message to enable tab traversal. If
> WM_KEYUP (value = 257) is also a condition for this if-statement, the
> javascript behaves as expected. On a more general note, I'm not sure
> why we're only catching certain events here. I figured this out by
> removing the if-statement altogether and simply translating all
> events, and didn't see any negative effects immediately. E.g., this
> was my revised MSWTranslateMessage method in its entirety:

> def MSWTranslateMessage(self, msg):
> res = self.ipao.TranslateAccelerator(msg)
> return res == hr.S_OK

> Again, someone who has a better handle on how this all works should
> look at the effects of the above.

I expect that the above is the right way to do it, although it should
probably still give the base class version of the method a chance to run
so wx can still deal with accelerators, etc. Like I said I just
translated that code to Python from a C++ example I saw someplace, and
I've always suspected it a little bit. Thanks for experimenting with this.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Steve Willis wrote:

Yes, the above MSWTranslateMessage is ultimately what I used in a
custom IEHtmlWindow subclass, rather than the base activex class. I
would recommend it for inclusion in the official IEHtmlWindow class. I
also came across the C/C++ code you translated this from, and it
appears to be a workaround for a bug in wxWidgets that has since been
corrected, so I think it is safe to disable the accelerator key code
in any case.

If you add an accelerator on one of the menu items in your frame's MenuBar does it still work? (Looking at the source code of the base classes that seems to be the only thing that could break if the base MSWTranslateMessage is not allowed to peek at the windows messages.)

···

--
Robin Dunn
Software Craftsman