Guidance Forums / wxWidgets (wxWindows) in C++ / Newbie: how to draw on screen (DC)?

Search 搜索
Home Home

Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Newbie: how to draw on screen (DC)?
Posted by: 2004-03-19 00:49:25
I'm a total newbie to wxWidgets. My wish is draw some graphics (using wxDC:DrawCircle() and such) on the screen. So far I've managed to compile the minimal example that comes with the distribution, and even add a wxTextCtrl to it. I didn't experience that kind of success when trying to add a wxDC widget. q1: how do I add a functioning device context to my frame?
q2: my ultimate goal is some (simple, geometric) animation. what's the best way to go about it?
thanx, avish.
Message2. Re: Newbie: how to draw on screen (DC)?
Posted by: upCASE 2004-03-20 23:50:38
Well, you can't "add" a wxDC to your app like a wxTextCtrl or such. A DC is, as you said, a device context and basically is some space you can draw on. You'll have to create one of the following wxDC classes in order to start drawing:
wxScreenDC (for drawing on the whole screen)
wxClientDC (drawing on the client area of a window)
wxWindowDC (drawing on the whole window area)
There's also wxPaintDC which can only bve used inside the Pain Event Handler.

Normaly you will want to draw on some kind of canvas. A simple wxPanel is ok most of the times. Create a panle inside your frame, create a wxClientDC(pointer_to_panel) and then draw on the dc.
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
© Thu 2024-5-30  Guidance Laboratory Inc. Hits:0