You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何创建无背景/透明背景的Trackbar?及相关绘制问题咨询

自定义Trackbar的核心问题
  • Trackbar背景默认继承父控件颜色,无法透明以显示下方图像,需了解背景绘制的时机、对应的DrawStage或ItemSpec参数。
  • 已扩展滑块(thumb)的矩形范围,但无法告知系统该变化,只能通过Invalidate()重绘,导致拖动滑块时存在闪烁。

以下是当前滑块绘制代码:

if(lpDraw->dwItemSpec == TBCD_THUMB)
{
    if(Orientation != trVertical)
    {
        drct.Left += -5;
        drct.Right += 5;
        ::Graphics::TBitmap *bmp = new ::Graphics::TBitmap;
        bmp->Transparent = true;
        //bmp->LoadFromFile("UI\\slider2.bmp");
        bmp->LoadFromFile(buff + "\\UI\\slider2.bmp");
        m_pCanvas->CopyRect(drct,bmp->Canvas, TRect(0,0,bmp->Width,bmp->Height));
        delete bmp;
        Invalidate();
    }
    else
    {
        drct.bottom += 5;
        drct.top += -5;
        ::Graphics::TBitmap *bmp= new ::Graphics::TBitmap;
        bmp->Transparent = true;
        //bmp->LoadFromFile("UI\\slider.bmp");
        bmp->LoadFromFile(buff + "\\UI\\slider.bmp");
        m_pCanvas->CopyRect(drct, bmp->Canvas, TRect(0,0,bmp->Width,bmp->Height));
        delete bmp;
        Invalidate();
    }
}

内容的提问来源于stack exchange,提问作者thousandshadow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 15:08:19