Delphi   发布时间:2022-04-10  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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 – 在TLageControl上的TLinkLabel背景全部内容,希望文章能够帮你解决delphi – 在TLageControl上的TLinkLabel背景所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: