delphi – 在TLageControl上的TLinkLabel背景

我试图在TPageControl上使用TLinkLabel,我找不到一种方法来使其成为父级的背景.
// Image removed because the website doesn't exist any more 
// and I can't find it anywhere... Sorry.

您可以看到,父标签页的可爱渐变不会保留在链接文本后面.

我希望在流动的文本块(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,你几乎在那里,你对TLinkLabel的ControlStyle的更改.另外要做的还是要确保标准的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 API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...