screen flickering 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
zhouhao
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2005 7:02 am

screen flickering

Post by zhouhao »

I'm tring to mix the components with the wxWidgets drawing in a wxPanel. Here is part of my code:

Code: Select all


//////////////////////////////////////////////////
//  inside my panel's constructor
	wxString wxRadioBoxChoices_RadioBox1[2];
	wxRadioBoxChoices_RadioBox1[0] = _("Option 1");
	wxRadioBoxChoices_RadioBox1[1] = _("Option 2");
	RadioBox1 = new wxRadioBox(this,ID_RADIOBOX1,_T(""),wxPoint(0,77),wxSize(124,109),2,wxRadioBoxChoices_RadioBox1,1,0);

    m_bmpSprite.LoadFile(_T("sprites.png"),wxBITMAP_TYPE_PNG);

//////////////////////////////////////////////////////
// inside my onPaint event
	wxBufferedPaintDC dc(this);
	wxASSERT(TRUE == dc.Ok());

    dc.SetBackground(*wxWHITE_BRUSH);
    dc.Clear();
    dc.DrawBitmap(m_bmpSprite, m_iX+i, 0+i*20, true);


////////////////////////////////////////////////////////
// inside my onTimer event which is trigger every 50ms
	int w,h;
	GetClientSize(&w,&h);

    if ( m_iX < w && m_iX >= 100 )
        m_iX += 1;
    else
        m_iX = 100;

   Refresh();
My animation is working fine. But the problem is the Radiobox is always flickering. Can anybody help?

[/code]
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

Add this before you create rhe radio box

Code: Select all

wxSystemOptions::SetOption(_T("msw.staticbox.optimized-paint"), 0);
zhouhao
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2005 7:02 am

Post by zhouhao »

Thanks for your reply. But the effect is that the background of the radiobox becomes transparent and the flickers still exist.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

do you draw your sprite over your radiobutton? If not, try using wxWindow::RefreshRect and refresh only the area where your sprite moves
Use the source, Luke!
zhouhao
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2005 7:02 am

Post by zhouhao »

doublemax wrote:do you draw your sprite over your radiobutton? If not, try using wxWindow::RefreshRect and refresh only the area where your sprite moves
That's cool. It works. Thank you.
Post Reply