我试图在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;
原文地址:https://www.jb51.cc/delphi/102546.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。