使用 VB.NET 菜单区域中的透明标签
我读过很多关于如何创建透明标签的文章,但在我看来,我的具体情况并未涵盖。非常简单,我在表单的右上方放置了一个标签,它实际上是菜单条的一部分。该标签向用户显示一些信息,但我希望它是透明的。我尝试过各种方法,包括
lblAct.Parent = mnuMain '(or Me)
lblAct.BackColor = Color.Transparent
lblAct.BringToFront()
但无法使其发挥作用。有人对我如何使该位置的标签透明有什么建议吗?
感谢
AGP
I've read many articles on how to create transparent labels but it seems to me that my particular case is not covered. Very simply I have a label placed in the upper right part of the form, which in fact is part of the menu strip. The label displays some info to the user but I wish it were transparent. Ive tried various methods including
lblAct.Parent = mnuMain '(or Me)
lblAct.BackColor = Color.Transparent
lblAct.BringToFront()
but cant get it to work. Anyone have suggestions on how I can make that lable in that position transparent?
Thanks
AGP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你无法完成这项工作。这是Windows的限制,透明效果是相对于顶层窗口的,堆叠效果不起作用。您将看到表单作为背景,而不是菜单条。破解一个要求菜单条渲染自身以创建背景的标签在技术上是可能的。但当条带自行重新绘制时,Windows 不会生成绘制消息。例如,当用户调整表单大小时,这一点将非常明显。
Yes, you can't make this work. It's a Windows restriction, transparency effects are relative to the top-level window, stacking effects do not work. You'll see the form as the background, not the menu strip. Hacking a label that asks the menustrip to render itself to create the background is technically possible. But Windows won't generate a paint message when the strip repaints itself. Which will be starkly visible when the user resizes the form for example.