[wxBufferedPaintDC] Stacking DCs across multiple windows causes
bad redraw
Julian Smart
julian at anthemion.co.uk
Wed Aug 22 05:51:01 PDT 2007
Hi Mario,
Mario Figueiredo wrote:
> Hello everyone,
>
> If I have one onPaint event drawing on a window through
> wxBufferedPaintDC and from there directly, or indirectly, I end up
> calling another window OnPaint event which also uses a
> wxBufferedPaintDC, the first window doesn't get properly updated.
>
> I can enter into more details about it on how I'm experiencing this
> behavior, but if it is not necessary, consider two windows sitting
> inside the same container. One of the windows OnPaint() explicitly
> calls the other window OnPaint() or does so indirectly, for instance
> by changing a data member of that window that triggers a custom event
> processed by OnPaint().
>
> I'm unsure at this point - and I can't be at the moment I'm writing
> this - that wxPaintDC displays similar behavior. But I reckon it does.
>
> I would like to understand why this happens and if there is some way I
> can safely stack DCs usage across multiple windows.
>
Normally this situation won't occur because paint event handlers are not
called immediately - they are processed one after the other by the
application's event loop. If you call Refresh() from a paint handler, it
just queues a paint event. If, however, you called Refresh() followed by
an Update() from a paint handler, then that could cause problems since
Update() will try to process paint events immediately. So, just avoid
calling Update() within a paint event handler, and certainly don't
attempt to call a paint event handler directly.
Regards,
Julian
More information about the wx-users
mailing list