在屏幕上绘制字符串 C#
我想简单地在屏幕上(在特定位置)绘制一个字符串(如果可能的话,以特定字体和大小)。我在 C# Windows 窗体应用程序中。不幸的是,我在网上找不到任何关于如何执行此操作的提示。
请帮忙!
基督教
I would like to simply draw a string (if possible in a specific font and size) on the screen (at a specific location). I am within a C# windows forms application. Unfortunately, I could not found any hint on how to do this in the web.
Please help!
Christian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要在窗口外绘制字符串,您必须创建一个新窗口,将其蒙版设置为某种颜色(例如洋红色),然后在其上绘制文本 - 您可以在此处使用简单的标签。
将窗口边框样式设置为“无”,然后就可以了。
换句话说,没有附加窗口就无法显示“自由文本”。
对于遮罩颜色,请使用“透明颜色”或类似属性(我稍后会查找它 - 手头没有 VS)
To draw a string outside of your window, you'll have to CREATE a new window, set it's mask to some color (say magenta) and then draw text onto it - you can use simple label here.
Set your window border style to None, and there you go.
In other words, there is no way of displaying 'free text' without window attached.
For masking color, use 'transparency color' or similar property (I will look up into it later - have no VS at hand)
并不真正建议您执行您要求的操作,请参阅 链接
如果你真的想做这样的事情;这是一种令人毛骨悚然的方法:
请注意,我不建议任何人这样做,因为我认为应用程序不应该做这样的事情。如果您想画一些东西,您应该在自己的表单/控件上进行。
doing what you are asking for is not really recommended, see e.g. Link
If you really want to do something like this; here is a creepy way to do it:
Please note that I DON'T recommend anyone doing this as I don't think applications should be doing stuff like this. If you want to draw something you should do it on your own form/controls.
检查这个。
或者您可能正在寻找 DrawString 方法
希望这会有所帮助
Check this out.
Or may be you are looking for DrawString method
Hope this will help