windows aero glass form 文字问题 [英] Windows aero glass form text problem

查看:69
本文介绍了windows aero glass form 文字问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有 GlassForm 的 Windows 窗体(使用 Microsoft.WindowsAPICodePack.Shell;).当我将表单更改为 GlassForm 时,我的问题是我的文本框文本没有

I use windows form with GlassForm(using Microsoft.WindowsAPICodePack.Shell;). my problem when I change form to GlassForm my textbox texts doesnt

推荐答案

是的,它就是这样工作的.应用 Aero Glass 效果后,任何以黑色绘制的内容都将渲染为透明.这包括文本框控件中的文本.这个通用主题一直是许多其他问题的主题 这里.如果写得好,他们会获得很多赞,但答案很少.

Yes, that's how it works. With the Aero Glass effect applied, anything drawn in the color black will be rendered as transparent. That includes text in a textbox control. This general theme has been the subject of many other questions here. When well-written, they gather lots of upvotes, but few answers.

这里没有很多好的解决方案.我遇到的所有这些都符合丑陋"和骇人听闻"的资格.当您使用诸如标签控件之类的东西时,所有者绘制是一种合理的方法,但我不建议您尝试绘制自己的文本框——这太难了.有人在这里尝试这样做;就像我说的,结果既丑陋又骇人听闻.我对自己的使用并不满意,但它可能对你有用,这取决于你的标准有多高.

There just aren't a lot of good solutions here. All of them that I've come across qualify as both "ugly" and "hackish". Owner-drawing is a reasonable approach when you're using something like a label control, but I wouldn't recommend trying to draw your own textbox—it's just too hard to get right. Someone tried to do that here; like I said, the result is both ugly and hackish. I wasn't satisfied with it for my own use, but it may work for you, depending on how high your standards are.

当然,所有者绘图的目标是使用 GDI+(本机支持透明度)而不是 GDI(所有内置控件默认使用)来完成所有绘图,或者调用类似的函数DrawThemeTextEx,专为使用在玻璃上[有些]可读的阴影渲染文本.

The goal with owner-drawing, of course, is either to do all of the drawing using GDI+ (which natively supports transparency) instead of GDI (which all of the built-in controls use by default), or calling functions like DrawThemeTextEx, which is specifically designed for rendering text with a shadow that is [somewhat] readable over glass.

同样,启用兼容文本渲染(这会导致内置控件使用 GDI+ 例程进行绘制,就像它们在 .NET 的早期版本中所做的那样)等常用技巧不适用于文本框.

As well, the usual tricks like enabling compatible text rendering (which causes the built-in controls to draw using GDI+ routines, as they did in the early versions of .NET) don't work for a textbox.

老实说,最好的办法是将文本框放在表单中呈现为玻璃的区域上.使用 DwmEnableBlurBehindWindow 函数 有选择地启用表单某些区域背后的玻璃效果,而不是整个事物.我在 我的答案在这里.

Honestly, your best bet is to place the textbox over a region of your form that is not rendered as glass. Use the DwmEnableBlurBehindWindow function to selectively enable the glass effect behind certain areas of your form, rather than the entire thing. I provide a complete, ready-to-use .NET implementation in my answer here.

这篇关于windows aero glass form 文字问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆