怎么可能把之前画的东西清除掉呢?
我正在使用 Delphi,并且正在使用 TControl 类构建自己的标签组件。 在根据属性(例如标题、字体等)绘制文本之前,我想清除绘制矩形,就像组件所在的位置没有任何东西一样。我的意思是我想让它像一块玻璃,以便显示它后面的其他组件;然后绘制文字。我应该如何将放置在标签后面的其他组件绘制到它上面?
I'm using Delphi and I'm building my own label component with class TControl.
Before I paint the text according to the properties (such as caption, font, etc.) I want to clear paint rect like there is nothing at the place of component. I mean I want to make it like a glass so that the other components behind it will be displayed; and then paint the text. What should I do to paint other components that are placed behind my label to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您无需执行任何操作。 :-)
当您制作类似透明标签的组件时,最好使用 TGraphicControl 基类。这实际上只不过是一块可以绘画的画布。每当内容需要更改时,您都可以调用
Invalidate
方法来重新绘制控件。这将调用您可以重写的Paint
方法。每次重新绘制时,您的控件都将变得清晰透明,除了您在Paint
方法中绘制内容的部分。To do that, you need to do nothing. :-)
When you make a transparent label-like component, you best use the TGraphicControl base class. This is actually little more than a canvas to paint on. Whenever the content should be changed, you call the
Invalidate
method to repaint your control. This will call thePaint
method that you can override. With every repaint, your control will be clear and transparent, except for the parts where you draw stuff in yourPaint
method.除非您覆盖并禁用背景绘画,否则您不需要执行任何操作。这取决于你想要什么基类。尽管您可以简单地使用(在 Paint() 方法中):
您还应该阅读 TControlCanvas。这是一个更深入地讨论此主题的网站: http://www.delphidabbler.com/tips/ 75
Unless you override and disable the background painting, then you dont need to do anything. It depends on what base-class you go for. Although you can simply use (in the Paint() method):
You should also read up on TControlCanvas. Here is a website that deals with this topic more in depth: http://www.delphidabbler.com/tips/75