绘制其他控件

扫码查看
本文介绍了绘制其他控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制一些文本,这些文本将出现在任何其他控件之前,

但是没有完全掩盖它们。如果我在'

形式的处理程序中使用DrawString,文本总是在后面,而不是在其他控件的前面。

在VB6中我会简单地使用标签控件并将其设置为透明,

但这在.NET中不起作用,标签的背景可以设置为

''透明'',但是这并没有显示其他控件,而是它使用表单背景填充后台的
。我肯定必须有一个简单的方法来实现这个目标,但我现在找不到它。

任何想法都会受到赞赏。

谢谢

菲尔。

(VB2005Express)

I would like to draw some text which will be in front of any other controls,
but without obscuring them completely. If I use DrawString in the form''s
Paint handler the text is always behind, not in front of the other controls.
In VB6 I would have simply used a label control and set it to transparent,
but this doesn''t work in .NET, the background of a label can be set to
''transparent'', but this does not show the other controls through, instead it
fills in the background with the form background. I''m sure there must be a
simple way to acheive this, but I can''t find it at the moment.
Any ideas appreciated.
Thanks
Phil.
(VB2005Express)

推荐答案



不幸的是因为表格是TopMost,这意味着它不仅会在现有表格的控件前显示
,还会显示在

所有其他窗口的前面,包括可能运行的其他应用程序。

另外设置ShowInTaskbar = False会停止在任务栏中显示的图标,

但是当按Alt + Tab切换

windows时,仍会显示表格的图标。

Unfortunately because the form is TopMost, this means not only does it
display in front of the controls on my existing form, it also displays in
front of all other windows, including other applications that might be
running.
Also setting ShowInTaskbar = False stops an icon showing in the task bar,
but an icon for the form is still shown when pressing Alt+Tab to switch
windows.





谢谢,我试过了。看起来这种方法可能很有前途,但是还有一些问题仍然存在。

如果我从表单上再切换回来,文本会消失,

虽然我可以通过将代码放在Form Paint事件中来解决这个问题。

还有任何重绘自己的控件(例如当你将鼠标悬停在
上时的按钮)
鼠标)将在文本上绘制自己。另一个问题是如果有另外一个窗口部分模糊了窗体,那么文本仍然可以在另一个窗口的顶部写入

。我想知道是否有可能将抽绳的

输出剪辑到表格的当前可见区域?


再次感谢您的帮助。非常感谢。

Phil。

Thanks, I tried it. It looks like this approach may be promising, but there
are still a couple of problems.
If I switch away from the form and back again, the text dissappears,
although I can get around this by placing the code in the Form Paint event.
Also any control that redraws itself (e.g. a button when you hover over with
the mouse) will draw itself over the text. Another problem is if there is
another window partly obscuring the form, the text can still get written
over the top of this other window. I wonder if it is possible to clip the
output of drawstring to the currently visible area of the form?

Thanks again for your help. It is very much appreciated.
Phil.


这篇关于绘制其他控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:09
查看更多