Help! How to clear the wxPaintDC field when resizing Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
alexmar12
Earned a small fee
Earned a small fee
Posts: 20
Joined: Tue Aug 23, 2022 1:14 pm

Help! How to clear the wxPaintDC field when resizing

Post by alexmar12 »

Hello. I can't clear the field after resizing in any way.

Code: Select all

void MainChart::OnPaint(wxPaintEvent &evt)
{
    wxPaintDC dc(this);
    wxSize size = this->GetSize();
    graphChart->SetCandles(dc, size);
}

Code: Select all

void GraphChart::SetCandles(wxPaintDC &dc, wxSize &size)
{
    dc.SetBrush(*wxWHITE_BRUSH);           // filling
    dc.SetPen(wxPen(wxColor(0, 0, 0), 1)); // 1-pixels-thick pink outline
    dc.DrawRectangle(0, 0, size.x, size.y);
}
When changing, it turns out like this

Image

How can I clear the field?
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 469
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Help! How to clear the wxPaintDC field when resizing

Post by New Pagodi »

Create the MainChart window with wxFULL_REPAINT_ON_RESIZE included in the style flag.
alexmar12
Earned a small fee
Earned a small fee
Posts: 20
Joined: Tue Aug 23, 2022 1:14 pm

Re: Help! How to clear the wxPaintDC field when resizing

Post by alexmar12 »

Thank you very much! It worked
Post Reply