Change wxPaintDC to wxBufferedPaintDC Topic is solved
Re: Change wxPaintDC to wxBufferedPaintDC
these were two windows wxScrolledWindow in wxFrame.
I have removed them and it does not work.
I have removed them and it does not work.
Re: Change wxPaintDC to wxBufferedPaintDC
Hi,
Can you post the constructor of the frame and the EVT_PAINT handler from the new code?
Thank you.
Can you post the constructor of the frame and the EVT_PAINT handler from the new code?
Thank you.
Re: Change wxPaintDC to wxBufferedPaintDC
I think PB almost confirmed with his test, that this is most likely a bug. Please open a ticket at http://trac.wxwidgets.orgpalikem wrote:these were two windows wxScrolledWindow in wxFrame.
I have removed them and it does not work.
Use the source, Luke!
Re: Change wxPaintDC to wxBufferedPaintDC
I need to resolve it as soon as possible.
I have to find another solution.
Everything that I draw, I have to recalculate.
My English is not so good, to report bugs in trac.wxwidgets.org
I have to find another solution.
Everything that I draw, I have to recalculate.
My English is not so good, to report bugs in trac.wxwidgets.org
Re: Change wxPaintDC to wxBufferedPaintDC
Try this as a workaround:
Old code:
New code:
Old code:
Code: Select all
wxPaintDC dc(this);
// start drawing code
dc.Clear();
dc.SetDeviceOrigin(0, dc.GetSize().GetHeight()-1 );
dc.SetAxisOrientation(true, true);
dc.DrawLine(0, 0, 100, 100);
dc.DrawText("Test Frame", 100, 100);
// end drawing code
Code: Select all
wxPaintDC pdc(this);
wxBitmap buffer( GetClientSize().x, GetClientSize().y, 24 );
wxMemoryDC dc(buffer);
dc.CopyAttributes( pdc );
// start drawing code (doesn't need to be changed. same as before)
dc.Clear();
dc.SetDeviceOrigin(0, dc.GetSize().GetHeight()-1);
dc.SetAxisOrientation(true, true);
dc.DrawLine(0, 0, 100, 100);
dc.DrawText("Test Frame", 100, 100);
// end drawing code
dc.SelectObject( wxNullBitmap );
pdc.DrawBitmap( buffer, 0, 0 );
Use the source, Luke!
Re: Change wxPaintDC to wxBufferedPaintDC
Thanks it works.
Will not blink with Refresh () ?
Will not blink with Refresh () ?
Re: Change wxPaintDC to wxBufferedPaintDC
It shouldn't.palikem wrote:Will not blink with Refresh () ?
If it flickers it's because the background of the window is still cleared by the OS. You can suppress that by having an empty wxEVT_ERASE_BACKGROUND event handler. Or by calling SetBackgroundStyle( wxBG_STYLE_PAINT ) after constructing the window.
Use the source, Luke!
Re: Change wxPaintDC to wxBufferedPaintDC
Thanks to doublemax.
Using SetBackgroundStyle (wxBG_STYLE_PAINT) not blinking.
Using SetBackgroundStyle (wxBG_STYLE_PAINT) not blinking.
Re: Change wxPaintDC to wxBufferedPaintDC
There is a problem.doublemax wrote:Try this as a workaround:
Old code:New code:Code: Select all
wxPaintDC dc(this); // start drawing code dc.Clear(); dc.SetDeviceOrigin(0, dc.GetSize().GetHeight()-1 ); dc.SetAxisOrientation(true, true); dc.DrawLine(0, 0, 100, 100); dc.DrawText("Test Frame", 100, 100); // end drawing code
Code: Select all
wxPaintDC pdc(this); wxBitmap buffer( GetClientSize().x, GetClientSize().y, 24 ); wxMemoryDC dc(buffer); dc.CopyAttributes( pdc ); // start drawing code (doesn't need to be changed. same as before) dc.Clear(); dc.SetDeviceOrigin(0, dc.GetSize().GetHeight()-1); dc.SetAxisOrientation(true, true); dc.DrawLine(0, 0, 100, 100); dc.DrawText("Test Frame", 100, 100); // end drawing code dc.SelectObject( wxNullBitmap ); pdc.DrawBitmap( buffer, 0, 0 );
So twice a day that kind of problem pops up.
And the new code destroys my bookmarks. I found the line. Drawing bookmarks through old code. Bookmarks draw through drawLine and drawarc.
Re: Change wxPaintDC to wxBufferedPaintDC
Regarding the assert message: There is definitely no leak in the code i posted, but it's still better to use a static bitmap for the buffer, instead of creating a new one each time.
You need to add a member variable "wxBitmap m_buffer;" to the class this method belongs to.
Regarding the broken arcs, i'd need some code to reproduce the issue. But it looks like a bug.
You need to add a member variable "wxBitmap m_buffer;" to the class this method belongs to.
Code: Select all
wxPaintDC pdc(this);
if( !m_buffer.IsOk() || m_buffer.GetWidth() != GetClientSize().x || m_buffer.GetHeight() != GetClientSize().y )
{
// you can also try depth=32 and check if it makes any difference
m_buffer = wxBitmap( GetClientSize().x, GetClientSize().y, 24 );
}
wxMemoryDC dc(buffer);
Use the source, Luke!
Re: Change wxPaintDC to wxBufferedPaintDC
Using wxPaintDC.
Using wxMemoryDC.
Code: Select all
void testbuffFrm::testbuffFrmPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
/*if( !m_buffer.IsOk() || m_buffer.GetWidth() != GetClientSize().x || m_buffer.GetHeight() != GetClientSize().y )
{
// you can also try depth=32 and check if it makes any difference
m_buffer = wxBitmap( GetClientSize().x, GetClientSize().y, 24 );
}
wxMemoryDC dc(m_buffer);
dc.CopyAttributes( pdc );*/
dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear();
//dc.SetDeviceOrigin(0, dc.GetSize().GetHeight()-1);
//dc.SetAxisOrientation(true, true);
dc.DrawLine(0, 61, 5, 61);
dc.DrawLine(5, 61, 5, 41);
dc.DrawArc(11, 37, 5, 43, 12, 44);
dc.DrawLine(11, 37, 50, 37);
//dc.SelectObject( wxNullBitmap );
//pdc.DrawBitmap( m_buffer, 0, 0 );
}
Code: Select all
void testbuffFrm::testbuffFrmPaint(wxPaintEvent& event)
{
wxPaintDC pdc(this);
if( !m_buffer.IsOk() || m_buffer.GetWidth() != GetClientSize().x || m_buffer.GetHeight() != GetClientSize().y )
{
// you can also try depth=32 and check if it makes any difference
m_buffer = wxBitmap( GetClientSize().x, GetClientSize().y, 24 );
}
wxMemoryDC dc(m_buffer);
dc.CopyAttributes( pdc );
dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear();
//dc.SetDeviceOrigin(0, dc.GetSize().GetHeight()-1);
//dc.SetAxisOrientation(true, true);
dc.DrawLine(0, 61, 5, 61);
dc.DrawLine(5, 61, 5, 41);
dc.DrawArc(11, 37, 5, 43, 12, 44);
dc.DrawLine(11, 37, 50, 37);
dc.SelectObject( wxNullBitmap );
pdc.DrawBitmap( m_buffer, 0, 0 );
}
Re: Change wxPaintDC to wxBufferedPaintDC
It did not help.doublemax wrote:Regarding the assert message: There is definitely no leak in the code i posted, but it's still better to use a static bitmap for the buffer, instead of creating a new one each time.
You need to add a member variable "wxBitmap m_buffer;" to the class this method belongs to.Regarding the broken arcs, i'd need some code to reproduce the issue. But it looks like a bug.Code: Select all
wxPaintDC pdc(this); if( !m_buffer.IsOk() || m_buffer.GetWidth() != GetClientSize().x || m_buffer.GetHeight() != GetClientSize().y ) { // you can also try depth=32 and check if it makes any difference m_buffer = wxBitmap( GetClientSize().x, GetClientSize().y, 24 ); } wxMemoryDC dc(buffer);
But I know when the program will do it.
When I give him to minimize and I'll open a directory on the desktop.
It is interesting, when I open the any file on the desktop, then it will not do it.
Re: Change wxPaintDC to wxBufferedPaintDC
I added :
It helped.
I just do not know if it's right
Code: Select all
void AdcFrm::AdcFrmPaint(wxPaintEvent& event)
{
if(wxGetActiveWindow() == this){
;
}else{
return;
}
.......
I just do not know if it's right
Re: Change wxPaintDC to wxBufferedPaintDC
That doesn't look right.
Regarding the initial problem with the incorrect drawing of the arc, add one line before it, then it should look ok.
Regarding the initial problem with the incorrect drawing of the arc, add one line before it, then it should look ok.
Code: Select all
dc.SetBrush( *wxTRANSPARENT_BRUSH ); /// new line
dc.DrawLine(0, 61, 5, 61);
dc.DrawLine(5, 61, 5, 41);
dc.DrawArc(11, 37, 5, 43, 12, 44);
dc.DrawLine(11, 37, 50, 37);
Use the source, Luke!
Re: Change wxPaintDC to wxBufferedPaintDC
Thank you doublemax.
I have already solved the problem with the arc.
Now I need to solve this problem: It will do so only when I minimize the program and open some directory on the desktop.
I can send a video, but where to insert the video?
I have already solved the problem with the arc.
Now I need to solve this problem: It will do so only when I minimize the program and open some directory on the desktop.
I can send a video, but where to insert the video?