获得.Net窗体的玻璃支持有几个技巧。帮助获取.Net WinForms应用程序以支持Vista Aero Glass
我想起了当初源出于此方法是在这里:http://blogs.msdn.com/tims/archive/2006/04/18/578637.aspx
基本上是:
//reference Desktop Windows Manager (DWM API)
[DllImport("dwmapi.dll")]
static extern void DwmIsCompositionEnabled(ref bool pfEnabled);
[DllImport("dwmapi.dll")]
static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
//then on form load
//check for Vista
if (Environment.OSVersion.Version.Major >= 6)
{
//check for support
bool isGlassSupported = false;
DwmIsCompositionEnabled(ref isGlassSupported);
if (isGlassSupported)
DwmExtendFrameIntoClientArea(this.Handle, ref margins);
...
//finally on print draw a black box over the alpha-ed area
//Before SP1 you could also use a black form background
这最后一步是问题 - 绘制在该区域的任何子控件似乎也把黑色作为alpha透明度面具。
例如,类区域上的标签条将具有透明文本。
有没有办法解决这个问题?
有没有更简单的方法来做到这一点?
我正在使用的应用程序必须在XP和Vista上都能正常工作 - 我需要它们适度地降级。这里有最佳做法吗?
谢谢,但这不适用于SP1后 - 它看起来像框必须是黑色的。 – Keith 2008-09-18 10:53:40