[python-win32] Drawing on the desktop and window creation problems

Tim Roberts timr at probo.com
Thu Sep 10 21:43:15 CEST 2009


Steve Bonam wrote:
> I create a new window but as soon it's drawn it is invisible, no
> titlebar, no anything. I draw text on it and it becomes white still
> has no titlebar and puts the text on twice. when I kill it from the
> interpeter the window finally becomes visible but not repsonsive as
> I've killed it's handling?
> ...
>
>
> # Create and register new window class
> def WndProc(hWnd, msg, wparam, lparam):
>     print msg
>     if msg == win32con.WM_PAINT:
>         print "Painting"
>         hdc,paintstruct = BeginPaint(hWnd)
>         PaintDesktop(hdc)
>         #ExtTextOut(hdc, 100,100,win32con.ETO_OPAQUE,None, "TEST")
>         EndPaint(hWnd,paintstruct)
>         return 0
>     if msg == 522:
>         PostQuitMessage(0)
>         return 0
>   

In a window proc, if you do not handle a message, you must forward it to
the default window proc.  This is not done automatically, so you aren't
getting the non-client painting and normal window management.  You
should add this as the last line in your WndProc:
    return DefWindowProc( hWnd, msg, wparam, lparam)

With that, you get a title bar and a border.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list