我正在尝试让一些非常微妙的东西发挥作用,它现在看起来非常糟糕。我正在尝试绘制 TGroupBox 的背景,我已重载了该 TGroupBox 的绘制函数,以便角落显示到其父对象。我有一堆嵌套的组框,在没有 XPThemes 的情况下看起来非常不错。
有没有办法在运行时将背景的一部分绘制为透明。我正在对表单生成器进行编程,而不是使用 Delphi 设计 View 。
最佳答案
当我遇到这样的情况时,我最初使用 TGroupBox,但后来决定使用 TPaintBox(在本示例中称为 pb)并模拟 TGroupBox 的图形部分。
procedure TfraNewRTMDisplay.pbPaint(Sender: TObject);
const
icMarginPixels=0;
icCornerElipsisDiameterPixels=10;
begin
pb.Canvas.Pen.Color:=clDkGray;
pb.Canvas.Pen.Width:=1;
pb.Canvas.Pen.Style:=psSolid;
pb.Canvas.Brush.Color:=m_iDisplayColor;
pb.Canvas.Brush.Style:=bsSolid;
pb.Canvas.RoundRect(icMarginPixels,
icMarginPixels,
pb.Width-icMarginPixels*2,
pb.Height-icMarginPixels*2,
icCornerElipsisDiameterPixels,
icCornerElipsisDiameterPixels);
end;
关于winforms - 如何绘制delphi组框具有透明背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/154387/