win32gui

Thomas Heller thomas.heller at ion-tof.com
Mon Jul 2 05:51:07 EDT 2001


Hi.

I'm trying to use the win32gui module.
I want to register a custom window class
with the following code:

import win32gui, win32con

def test(*args, **kw):
    print "test", args, kw

wndclass = win32gui.WNDCLASS()
wndclass.lpszClassName = "MyPythonWndClass"
wndclass.lpfnWndProc = test
print win32gui.RegisterClass(wndclass)

hwnd = win32gui.CreateWindow("MyPythonWndClass", .....)
win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)

win32gui.PumpMessages()

All this (basically) works, the window is shown,
but nothing is printed from the test function.
Wading with the debugger through the code, it seems
the 'test' function is never called.
The reason seems to be that the default window-proc
from win32gui is called, and SetClassLong() is never
called with 'test' as the parameter.
Has anyone got this to work? Am I doning something wrong?

Thomas





More information about the Python-list mailing list