[python-win32] ActiveX components with Events
Neil Benn
benn at cenix-bioscience.com
Fri Dec 17 16:40:13 CET 2004
Hihn, Jason wrote:
>I will attempt to use my psychic powers and read into this situation
>more than you have told.
>
>
>That ActiveX is coded in VB, hence the OCX. The VB is calling
>form.show(). I bet (if all previous assumptiona are correct) that you
>could fix the subliminal message by calling form.load()
>
>I will stop now before people start thinking that I am proud of knowing
>VB.
>
>
>
<snip>
Hello,
I'm sorry but I'm having real trouble trying to get this
across, please see the comment embedded in my original e-mail beneath :
<Last e-mail>
Sorry that was a bad explanation - the control _is_ an ActiveX exe - not
an ocx - it simply brings up a form (which in actual fact I then hide
immediately, I can't stop the form appearing in the first place - it has
to appear for a few millisecs like a subliminal message).
</Last e-mail>
The component is _not_ an ocx - I don't even know (or care) what the
original programming language was, I guess its C++ but it doesn't (or
shouldn't) concern me. The component is an ActiveX exe which is an out
of process exe - I didn't write it and I don't have the source code. I
have successfully interacted with the ActiveX component using Java and
Jacob (a Java/COM bridge) using the interface supplied by the
manufacturer. The only reason that I'm quoting VB code is because I
assumed that there would more people here who know VB than know Java/Jacob!
Therefore the underlying component is trying to bring up a form, in
order to give it the processor time to handle that I need to allow the
OS to process the windows message (this is the bit that is written
incorrectly in the ActiveX as they should be managing this themselves).
The way to do this in VB is to use a method called DoEvents. The
DoEvents method basically calls PeekMessage and DispatchMessage for all
messages waiting on the events queue and then returns into my process.
Essentially this is what pythoncom.PumpWaitingMessages does.
However this still doesn't work, I cannot get events. Looking at
the behavior in other code, an event is fired just before the form is
shown, if this event is blocked in the EventHandkler then the ActiveX
exe will hang on the completion. Thereby stopping the code which
displays the form from being executed in the component ActiveX.
However upon inserted the pythomcom.PumpWaitingMessages, I still
cannot capture any events from this ActiveX exe. I even wrote a very
very simple test case which creates an ActiveX dll with the following code :
public event Event1
public sub FireEvent()
RaiseEvent Event1
the python code had
.>>>def class EventHandler:
.>>> def Event1(self):
.>>> print 'event fired'
.>>>objTest = DispatchWithEvents("TestDll.cTest", EventHandler)
.>>>objTest.FireEvent()
This should have captured the event and displayed the test 'event
fired' on the screen. Nothing happened - I know I have a correct
install because the IE6 example supplied in the docs in the source file
for win32\client\__init__.py works fine.
If there is any other information that could help to determine my
problem then please let me know. I appreciate your help - as I have
managed to boil my problem down to a very simple test case then the fine
details of the original ActiveX exe (__not__ an OCX) are by the by.
This test case removes that element from the equation.
Cheers,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : benn at cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com
More information about the Python-win32
mailing list