[python-win32] Custom control, WS_CHILD

Henry Baxter henry.baxter at gmail.com
Sat Jan 12 10:42:22 CET 2008


Hello,

I have been doing some win32 programming using ctypes. I have successfully
created windows, common controls, manipulated and shown images, and so
forth. However, I am having trouble with custom controls.

I can create a new window class, successfully register it, then successfully
create a child window.

When the parent window gets the UpdateWindow call, the program crashes. If I
set the style of the child to not include WS_VISIBLE, the program does not
crash, but the window of course does not appear. If I then call ShowWindow
on the child window, the program crashes.

I have carefully monitored the windows messages that are being seen by the
main window's procedure and the child window's procedure, and the crash
always happens right after the first WM_PAINT to the parent window. No
further messages are seen by either procedure before it crashes. Before the
crash both procedures process normal messages like WM_CREATE etc.


Backing up a step, I started from scratch with a main window and a normal
child button control, made sure it worked fine, then used SetWindowLong to
replace the window procedure on the child control. This works fine as long
as I don't replace the window procedure too early - if I replace it before
the first call to UpdateWindow in the startup procedure of the application,
the program once again crashes (and I really do believe these two problems
are related).


Basically, it seems that I am missing something vital from my windows
procedure that has something to do with the window being a WS_CHILD, and to
do with creation or painting. The system's button window procedure has it,
and my main window doesn't need it, but my custom child control does.

For testing purposes I call DefWindowProc with the appropriate arguments,
and don't do anything else in the child window's procedure. Is there
something else I need to do though?



I'm really stuck, really confused. Any suggestions?



-- 
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080112/1102d760/attachment.htm 


More information about the python-win32 mailing list