Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Newbie: how to draw on screen (DC)?

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Newbie: how to draw on screen (DC)?
#3525
Posted by: 2004-03-19 00:49:25
Hi,
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)?
#3538
Posted by: upCASE 2004-03-20 23:50:38
Hi!
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.
upCASE
-----------------------------------
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
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-4-19  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0