我试图在 TPageControl 上使用 TLinkLabel,但找不到让它使用父级背景的方法。
// Image removed because the website doesn't exist any more
// and I can't find it anywhere... Sorry.
正如您所看到的,父选项卡的可爱渐变没有保留在链接文本后面。
我想要在流动的文本块中具有多个链接的功能(TLinkLabel 提供的功能)and在文本后面显示父母的背景。
TLinkLabel 没有 ParentBackground 属性。我尝试创建一个派生类,将 csParentBackground 添加到控件样式中,但无济于事:
TMyLinkLabel = class (TLinkLabel)
public
constructor Create(AOwner: TComponent); override;
end;
...
constructor TMyLinkLabel.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle - [csOpaque] + [csParentBackground]
end;
有人有主意吗?
Nat,您即将完成对ControlStyle
of the TLinkLabel
。此外,您还需要确保标准 Windows 静态控件的父级(这就是TLinkLabel
是)处理WM_CTLCOLORSTATIC
消息正确。
VCL 有一个很好的重定向机制,可以让控件自行处理作为通知发送到其父窗口的消息。利用这个可以创建一个完全独立的透明链接标签:
type
TTransparentLinkLabel = class(TLinkLabel)
private
procedure CNCtlColorStatic(var AMsg: TWMCtlColorStatic);
message CN_CTLCOLORSTATIC;
public
constructor Create(AOwner: TComponent); override;
end;
constructor TTransparentLinkLabel.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle - [csOpaque] + [csParentBackground];
end;
procedure TTransparentLinkLabel.CNCtlColorStatic(var AMsg: TWMCtlColorStatic);
begin
SetBkMode(AMsg.ChildDC, TRANSPARENT);
AMsg.Result := GetStockObject(NULL_BRUSH);
end;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)