Trying the impossible?

Sebastian Wangnick sebastian.wangnick at eurocontrol.int
Sat Sep 21 10:32:26 CEST 2002


Dear all,

I'm trying to overload, using dynwin/calldll under Windows, the
Tkinter drawing routines to perform some additional drawing on top of
Tk.

My first attempt was to bind to "<Expose>", but this binding seemingly
is triggered before Tk performs its drawing, so my stuff was erased by
Tk :(

Now I'm trying to overload the WindowProc itself. To test the
mechanism, I started by simply passing everything on to
CallWindowProc:

from Tkinter import *
import dynwin
import dynwin.gencb
import dynwin.windll
import dynwin.winwin
user32 = dynwin.windll.module ('user32')

def my_winproc (hwnd, message, wparam, lparam):
    return user32.CallWindowProc (tk_winproc,
        hwnd, message, wparam, lparam)
my_winproc_cb = dynwin.gencb.generated_callback ('llll', my_winproc)

def map (event):
    global tk_winproc
    hwnd = frame.winfo_id()
    tk_winproc = user32.GetWindowLong (hwnd,
        dynwin.winwin.GWL_WNDPROC)
    user32.SetWindowLong (hwnd, dynwin.winwin.GWL_WNDPROC,
        my_winproc_cb.address)

root = Tk()
frame = Frame(root,width=100,height=100)
frame.pack(fill=BOTH,expand=1)
frame.bind("<Map>",map,"+")
root.mainloop()

However, when starting this it crashes with 'The instruction at
"0x1e0381fa" referenced memory at "0x00000008". The memory could not
be "read".'

Any idea what I'm doing wrong? I'm using XP, btw.

Regards,
Sebastian



More information about the Python-list mailing list