使用 VB.NET 菜单区域中的透明标签

发布于 2024-09-15 10:35:19 字数 293 浏览 3 评论 0原文

我读过很多关于如何创建透明标签的文章,但在我看来,我的具体情况并未涵盖。非常简单,我在表单的右上方放置了一个标签,它实际上是菜单条的一部分。该标签向用户显示一些信息,但我希望它是透明的。我尝试过各种方法,包括

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜空下最亮的亮点 2024-09-22 10:35:19

是的,你无法完成这项工作。这是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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文