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.
zhouhao
Earned some good credits
Posts: 144 Joined: Tue Dec 06, 2005 7:02 am
Post
by zhouhao » Sun Jul 30, 2006 6:30 am
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
Posts: 205 Joined: Wed Mar 30, 2005 10:56 pm
Post
by Jamie » Sun Jul 30, 2006 8:48 am
Add this before you create rhe radio box
Code: Select all
wxSystemOptions::SetOption(_T("msw.staticbox.optimized-paint"), 0);
zhouhao
Earned some good credits
Posts: 144 Joined: Tue Dec 06, 2005 7:02 am
Post
by zhouhao » Sun Jul 30, 2006 2:03 pm
Thanks for your reply. But the effect is that the background of the radiobox becomes transparent and the flickers still exist.
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sun Jul 30, 2006 5:45 pm
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
Posts: 144 Joined: Tue Dec 06, 2005 7:02 am
Post
by zhouhao » Mon Jul 31, 2006 12:58 am
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.