I use the following code to present a polygon:
wxDC dc;
wxPoint *points = GetPoints();
MyFrame *frame = new MyFrame();
frame->PrepareDC(dc);
dc.BeginDrawing();
dc.SetPen(*wxCYAN_PEN);
dc.DrawPolygon(size, points);
dc.EndDrawing();
frame->Show(true);
But the frame had not display any polygons, what was wrong?
Couldn't draw polygon with wxDC:: DrawPolygon
-
- Earned some good credits
- Posts: 120
- Joined: Sun Aug 29, 2004 3:09 pm
- Location: Grenoble, France
- Contact:
Here is you writing code ? Is it in wxPaintEvent handling ?
At the end of your code, you use a frame->Show witch show the window and refresh its content.
You can draw on a window where you want but if you don not draw it in a wxPaintEvent handling function, yours modifs will be discarded.
You must write :
void MyWindow::OnPaint(wxPaintEvent &)
{
wxPaintDC dc(this);
dc.BeginDrawing();
dc.SetPen(*wxCYAN_PEN);
dc.DrawPolygon(size, points);
dc.EndDrawing();
}
and intercept it :
BEGIN_EVENT_TABLE(MyWindow, ...)
EVT_PAINT (MyWindow::OnPaint)
// ...
END_EVENT_TABLE()
see : http://www.wxwidgets.org/manuals/2.5.4/ ... #wxpaintdc
At the end of your code, you use a frame->Show witch show the window and refresh its content.
You can draw on a window where you want but if you don not draw it in a wxPaintEvent handling function, yours modifs will be discarded.
You must write :
void MyWindow::OnPaint(wxPaintEvent &)
{
wxPaintDC dc(this);
dc.BeginDrawing();
dc.SetPen(*wxCYAN_PEN);
dc.DrawPolygon(size, points);
dc.EndDrawing();
}
and intercept it :
BEGIN_EVENT_TABLE(MyWindow, ...)
EVT_PAINT (MyWindow::OnPaint)
// ...
END_EVENT_TABLE()
see : http://www.wxwidgets.org/manuals/2.5.4/ ... #wxpaintdc