问题描述
我已经阅读了许多有关如何创建透明标签的文章,但在我看来,我的特殊情况并未涵盖.很简单,我在表单的右上角放置了一个标签,它实际上是菜单条的一部分.标签向用户显示一些信息,但我希望它是透明的.香港专业教育学院尝试了各种方法,包括
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?
谢谢
AGP
推荐答案
是的,您无法完成这项工作.这是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.
这篇关于使用VB.NET的菜单区域中的透明标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!