温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

wxWidgets第六课 EVT_ERASE_BACKGROUND背景擦除事件

发布时间:2020-07-14 12:11:55 来源:网络 阅读:863 作者:fengyuzaitu 栏目:系统运维

说明

      默认情况下,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<width-4; i=i+averageGap)

{

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);

}


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI