windows 我可以在 Form 上绘制,尤其是在所有控件上吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7060555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:51:22  来源:igfitidea点击:

Can I draw on a Form, above all controls?

c#windowsformsgraphicsdraw

提问by Mark Segal

Is it possible for me to draw ABOVE all controls on a form?
I have some controls (textboxes, buttons, COM objects) on my form,and I wish to draw ON them, overriding any pixels previously drawn by them.
I am using Windows Formson C#.
NOTE: the Graphicsclass draws under the controls...

我可以在 a 上绘制所有控件form吗?
我有一些控件 ( textboxes, buttons, COM objects)form,并且我希望在它们上绘制,覆盖以前由它们绘制的任何像素。
我使用Windows FormsC#
注意:Graphics该类在控件下绘制...

采纳答案by Jay Riggs

Take a look at the code in this article:

看一下这篇文章中的代码:

Draw Over WinForms Controls

在 WinForms 控件上绘制

The author has created a component that (as he describes it) is like a piece of glass over your form. Your code then draws on this 'glass,' over controls, the form it overlays, etc.

作者创建了一个组件(正如他所描述的那样)就像是表单上的一块玻璃。然后你的代码在这个“玻璃”上绘制,在控件上,它覆盖的表单等等。

One serious limitation which will affect you is that it does not draw over some controls (including the TextBox). These limitations (and the reasons for them) are described in the article but the code in the article might be what you're looking for (or might serve as a starting point for your own solution).

会影响您的一个严重限制是它不会绘制某些控件(包括 TextBox)。文章中描述了这些限制(及其原因),但文章中的代码可能是您正在寻找的(或者可以作为您自己的解决方案的起点)。