gpt4 book ai didi

delphi - TPageControl 上的 TLinkLabel 背景

转载 作者:行者123 更新时间:2023-12-03 14:38:52 27 4
gpt4 key购买 nike

我正在尝试在 TPageControl 上使用 TLinkLabel,但找不到让它使用其父级背景的方法。

// Image removed because the website doesn't exist any more 
// and I can't find it anywhere... Sorry.

正如您所看到的,父选项卡的可爱渐变没有保留在链接文本后面。

我希望在流动的文本 block 中具有多个链接的功能(TLinkLabel 提供的功能)并且在文本后面显示父级的背景。

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,您即将完成对 TLinkLabelControlStyle 的更改。此外,您还需要确保标准 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;

关于delphi - TPageControl 上的 TLinkLabel 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1345316/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com