我是delphi编程的新手:(我正在尝试使用透明背景图层和带圆圈形状的顶层制作自定义组件.但是,下面的代码在添加到表单时工作正常.例外情况是是否有另一个组件与自定义组件重叠或顶部,它位于下方但未显示.我在下面的表单上尝试过
BadgeTest1.BringToFront;
BadgeTest1.ComponentIndex:=2;
IndexVal:= BadgeTest1.ComponentIndex;
Run Code Online (Sandbox Code Playgroud)
但是,仍然没有工作.无论如何,定制组件是否显示在其他组件之上?只有圆形部分?另外,我一直试图在自定义组件的中心(水平和垂直)放置一个标题,我尝试过TextOut()程序.如果有更好的选择,请告诉我?下面是我的名为BadgeTest的自定义组件的代码.请帮忙,非常感谢你!
type
TBadgeTest=class(TGraphicControl)
private
FCaption:TCaption;
FColor:TColor;
FLayers:TLayerCollection;
FHeight:Integer;
FWidth:Integer;
protected
procedure Paint; override;
procedure SetBkgLayer;
procedure SetSecondLayer;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Caption:TCaption read FCaption write FCaption;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample', [TBadgeTest]);
end;
constructor TBadgeTest.Create(AOwner: TComponent);
var
ACanvas:TcxCanvas;
begin
inherited;
FHeight:=20;
Self.Height:=FHeight;
Constraints.MaxHeight:=20;
Constraints.MinHeight:=20;
FHeight:=20;
Self.Width:=FWidth;
Constraints.MaxWidth:=20;
Constraints.MinWidth:=20;
end;
destructor TBadgeTest.Destroy;
begin
inherited;
end;
procedure TBadgeTest.SetBkgLayer;
var
Bitmap:TBitmap32;
Layer: TCustomLayer;
begin
FLayers := TLayerCollection.Create(Self);
Layer := …Run Code Online (Sandbox Code Playgroud) 关于Delphi XE的快速问题.
我正在尝试制作具有透明背景的自定义圆形组件,以便在添加到表单上时,组件可以与其他组件重叠.我已经尝试过Brush.Style:=bsTransparent;或者ellipse()更多...但仍然无法找到使边缘区域透明的方法.
反正我是否可以在不使用其他lib或api的情况下使组件的边缘区域透明?