wxWidgets第六课EVT_ERASE_BACKGROUND背景擦除事件
说明
成都创新互联自2013年起,先为南县等服务建站,南县等地企业,进行企业商务咨询服务。为南县企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
默认情况下,OnEraseBackground函数负责背景颜色的渲染,OnPaint函数负责前景颜色的渲染。系统提供的默认的背景颜色函数将背景渲染成白色,会引起控件区域闪烁。可以通过重写背景擦除事件处理函数,减少闪烁
例子
void OnEraseBackground(wxEraseEvent& event);
EVT_ERASE_BACKGROUND(CDownLinkPlaybackSliderCtrl::OnEraseBackground)
void CDownLinkPlaybackSliderCtrl::OnEraseBackground(wxEraseEvent& event)
{
wxClientDC dc(this);
wxSize size = this->GetSize();
int width = size.GetWidth();
int height = size.GetHeight();
int middleHeight = height/2;
dc.SetPen(wxPen(*wxBLACK, 2));
// dc.DrawLine(0, middleHeight-1, width, middleHeight-1);
// dc.DrawLine(0, middleHeight+1, width, middleHeight+1);
dc.SetBrush(*wxBLACK_BRUSH);
dc.DrawRectangle(2, middleHeight-2, width-4, 4);
int topDialHeight = middleHeight-2;
int buttonDialHeight = middleHeight+2;
int averageGap = (width-4)/25;
int count = 0;
for (int i=2; i { dc.DrawLine(i, topDialHeight, i, topDialHeight-2); dc.DrawLine(i, buttonDialHeight, i, buttonDialHeight+2); if (count%4==0) { char szText[4] ={0}; sprintf(szText, "%d", count); wxRect rect(i-3, topDialHeight-2-3, 3, 3); dc.DrawLabel(szText, rect, 1); } count++; } dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(m_sliderLen-3, middleHeight - 2, 4, 6); }
新闻名称:wxWidgets第六课EVT_ERASE_BACKGROUND背景擦除事件
文章分享:http://scyanting.com/article/jhgjhs.html