User forums > General (but related to Code::Blocks)

Drawing on wxPanel outside the evt_paint.

(1/1)

nishalns:
Actually, i'm creating a simulator type application. Now, there is a panel called 'drawingPanel' on which they simulation takes place. Now, in my program I want to paint on this panel with another thread, 'simulationThread'. But when I try to paint on the panel from inside the Entry() function of the thread using wxDC, I get a "wx debug alert" message box, saying

--- Quote ---../../src/msw/dcclient.cpp(222):assert "Assert failure" failed in wxPaintDCImpl(): wxPaintDCImpl may be only created in EVT_PAINT handler! [in thread e0]

Do you want to stop the program?

You can also choose [cancel] to suppress further warnings.
--- End quote ---

And the program execution stops.

I do understand what the error message means, but I don't know how to fix it. Can somebody help?

stahta01:
If this is wxWidgets version 2.9 or higher please ask in the wxWidgets forum.

http://forums.wxwidgets.org/

If not, please state Compiler, Code::Blocks, and wxWidgets version info.

Tim S.

ollydbg:
This is a wxWidgets related question, so it is not related to C::B, so your topic may be locked.
But I can give you some direction:
1, it is generally not a good idea to draw GUI from a worker thread.

2, "wxPaintDCImpl may be only created in EVT_PAINT handler", you can't use wxPaintDC here, maybe you should try wxClientDC or other things I don't know.

3, http://forums.wxwidgets.org/ is a good place to ask.

nishalns:
Thanks all for your replies especially "ollydbg". I was actually using wxPaintDC and i changed to wxClientDC and wollah! it worked! Thank you very much.... ;D

Navigation

[0] Message Index

Go to full version