PPC 编程中的透明后台控件
您知道在 WinForm 中使用 Parent 方法很容易设置放置在其他控件顶部的控件的透明背景,如下所示:
LabelText.Parent = pictureBox1;
但它在 Windows Mobile 编程中不起作用。我想还有其他方法可以做到这一点。
我想将标签的背景设置为透明,放置在图片框上。在上图中,标签的背景颜色已设置为透明,但它显示白色而不是透明。
You know it is very easy to set transparent background of the control placed on the top of other control in WinForm by using the Parent method in C# like:
LabelText.Parent = pictureBox1;
But it does not work in the Windows Mobile programming. I thought there in an other way to do so.
I want to set the Label's background transparent, which is placed on the picturebox. In the above image the back colour of the label is already set to transparent but it displays the white colour instade of transparent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Winforms 没有真正的透明度。有一些用于虚假透明度的助手(如背景图像等),但它不是很强大。
查看 CodePlex 上的 Alpha Mobile Controls 项目。它应该可以解决你的问题。
The Winforms has no true transparency. There are some helpers for false transparency (like BackgroundImage, etc...) but it is not very powerfull.
Look at Alpha Mobile Controls project on CodePlex. It should solve your problem.
通过覆盖控件的 Windows 样式标志,您可以在 .NET 桌面版本上获得所需的透明度。您将覆盖 CreateParams 并打开 WS_EX_TRANSPARENT。
然而,这在 CF 上不可用。简单的解决方案是重写 PictureBox 的 Paint 事件并使用 Graphics.DrawText() 绘制文本。还有一个好处是它比标签控件便宜很多。
You can get the kind of transparency you are looking for on the desktop version of .NET by overriding the Windows style flags for a control. You'd override CreateParams and turn on WS_EX_TRANSPARENT.
That's however not available on CF. The simple solution is to just override the Paint event of the PictureBox and draw the text with Graphics.DrawText(). With the added benefit that this is a lot cheaper than a Label control.