Does the documentation say that?
The issue here is really one of philosophy. Consider your very first
example. You were trying to draw during the __init__ of your frame.
However, when wxFrame.__init__ runs, the window hasn't actually been
drawn yet. Nothing has changed on the screen. All of those
constructors just set up structures in memory, both in wx and in
Windows, and send off window events to trigger the rest of the creation
and drawing process. Those events all queue up until you run
wxApp().mainloop.
When mainloop runs, it starts pulling events off of the event queue and
running handlers. Some of those events include WM_CREATE, where window
initialization is done, WM_MOVE and WM_SIZE, which signal the position
and size of the window, and WM_PAINT, which requests a repaint of the
window. At the time you did your drawing, the window was invisible, so
when GDI went to clip your drawing request, it all went away, and the
drawing was ignored. However, once the window is visible, you can draw
on it (using ClientDC) from any event handler.
Drawing can only be done (reliably) from the application's main thread.
In a Windows application, the main thread is always dedicated to the
message loop. Thus, I guess it is accurate to say that you cannot
actually paint on a window outside of an event handler.
ยทยทยท
On Mon, 25 Jun 2007 17:58:17 +0900, Nekora <nekora@comcast.net> wrote:
Just out of curiosity, is there any way at all to do drawing outside
of an event handler for EVT_PAINT?Looking at the documentation, it appears that ClientDC -ought- to be
able to paint on a window at any time, outside of an event handler,
but it seems to be broken, from what you guys have told me. Now that
I got the PaintDC working inside of the event handler, ClientDCs
outside of it just don't want to work at all.Is ClientDC's documentation just wrong? (As in, It cannot actually
paint on a window outside of an event handler?)
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.