Problem with win32ui MessageBox
SSchukat at dspace.de
Mon Aug 20 19:07:50 CEST 2001
> "Maurizio Manetti" wrote:
> Alex Martelli wrote:
> > "Maurizio Manetti" <maurizio.manetti at arca.net> wrote in message
> > news:3B80ED4F.F37FA70 at arca.net...
> > > I have the following dummy script:
> > >
> > > import win32con
> > > import win32ui
> > >
> > > win32ui.MessageBox("Test Message", 'Test', win32con.MB_OK)
> > >
> > > When I run it from PythonWin it works as expected.
> > > If I save it on a script ".py" file and launch it (double click,
> > > associated with pythonw) I get the following error:
> > ...
> > > I found this problem on two different Win machine (Win98
> with Python 2.0
> > > and WinMe with Python 2.1.1)
> > >
> > > Does anyone know why? And how to solve the problem?
> > Works fine for me on NT4 with Python 2.1.1. I don't see any
> > obvious reason why it should fail so horribly, either.
> Yes, you are right, it's just a call to a windows API, but that's what
> happen to me.
> I also tried to reinstall pythonwin, but nothing changes.
The win32ui is not just a call into the windows API. It depends
on the framework used. Normally this is used in an application
which is based on the Python MFC wrapping by MarkH.
The pure windows API is implemented in the win32api module in
which your code would look like:
win32api.MessageBox(0, "Test Message", 'Test', win32con.MB_OK)
As you see there is an additional first parameter. This is
the HANDLE to the parent window which is filled automagically
in the win32ui environment.
But that is not your problem. The problem is a small error
in the win32ui implementation. Mark has used a windows hook
to do the message routing. This hook was added twice by accident in
a console app which caused an endless recursion and
therefore a stack overflow in Win9X/ME, but not on WinNT/2000.
The fix (more a hack) was included in the CVS sources at the 6. July.
So it may be included in ActivePython 211 (Ask Mark)
More information about the Python-list