[python-win32] SetClassLong on wx.PopupWindow breaks PyOpenGL and VTK

Andrea Gavana andrea.gavana at gmail.com
Mon Dec 10 23:23:50 CET 2007


Hi All,

    Sorry for the half off-topic question, but I am not sure if a
solution to this problem can be found in wxPython or in pywin32 (or in
ctypes). Using the class declared below, I am able to create a popup
window with some shadow on it (I use it for FlatMenu). When I
construct a popup window in this way, all the windows in my app which
contain an OpenGL widget or a VTK widget do not repaint their
background correctly (there is always an effect of see-through on
them). If I comment out the call to SetClassLong everything works fine
and the windows correctly repaint their background.
I seem to recall someone writing that calling SetClassLong on a single
window like that actually apply the shadowy style to all the windows
in the application. If this is correct, is there a workaround to this
problem? It's not easy to provide a sample app to demonstrate the
problem, but I'll do my best. In the meanwhile, could someone suggest
a possible cause/solution to this problem (even if it is a shot in the
dark)?

Thank you for any hint.

import wx
import win32api

class ShadowPopupWindow(wx.PopupWindow):
    """ Base class for generic FlatMenu derived from wx.PopupWindow. """

    def __init__(self):
        """ Default class constructor. """

        parent = wx.GetApp().GetTopWindow()

        if not parent:
            raise Exception("Can't create menu without parent!")

        wx.PopupWindow.__init__(self, parent)

        GCL_STYLE= -26
        cstyle= win32gui.GetClassLong(self.GetHandle(), GCL_STYLE)
        if cstyle & CS_DROPSHADOW == 0:
            win32api.SetClassLong(self.GetHandle(),
                                              GCL_STYLE, cstyle | CS_DROPSHADOW)


Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/


More information about the python-win32 mailing list