本文介绍了Windows Aero:涂什么颜色才能制成“玻璃”?出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在客户区域绘画什么颜色以使玻璃出现?



我已经扩展了表单的框架

  DwmExtendFrameIntoClientArea(self.Handle,margins);进入客户区。 

我找不到Microsoft提供的有关任何颜色和/或颜色的官方文档 alpha DWM将寻找替换玻璃的方法。






如果我忽略引用的MSDN主题,而是使用完全不透明的黑色(而不是完全透明的黑色):

  Color fillColor = Color.FromArgb(255,0, 0,0); //(a,r,g,b)
e.Graphics.FillRectangle(new SolidBrush(fillColor),e.ClipRectangle);

确实出现玻璃效果:






然后我会相信不透明黑色



但是我该如何在玻璃区域上涂黑色物品






我测试过在玻璃区域上画一个黑色的矩形,并带有一个 >旁边。奇怪的是,矩形没有出现,而圆圈却出现了;两者都是相同的颜色:

  Brush b = new SolidBrush(Color.FromArgb(255,0,0,0)); 
e.Graphics.FillRectangle(b,11,11,32,32);
e.Graphcis.FillEllipse(b,43,11,11,32,32);




那么世界到底是怎么回事?在扩展的框架区域中进行绘画以使玻璃出现的正确颜色是什么?






更新2



使用



FillEllipse不支持绘制黑色圆圈吗?






更新3









更新4



查看(围绕Vista功能的托管包装程序,不会添加到.NET中),它们只能设法在WPF表单,而不是WinForms。



另请参见







解决方案

其中一个对此进行了讨论。本机解决方案是使用 SetLayeredWindowAttributes 将颜色键从黑色切换为空。


What color must i paint in the client area in order to make glass appear?

i've extended the frame of my form into the client area using:

DwmExtendFrameIntoClientArea(self.Handle, margins);

i cannot find any official documentation from Microsoft on what color and/or alpha the DWM will look for to replace with glass. The documentation on DwmExtendFrameInClientArea doesn't even mention that a custom color is required. There's only hearsay and myth that a special color is even required.

The closest i can find is a topic on MSDN:

Update: And a blog post:

If i take what they say literally (pixel data with an alpha value of zero), i construct a color with zero alpha, and paint that in the extended area:

Color fillColor = Color.FromArgb(0, 0, 0, 0); //(a, r, g, b)
e.Graphics.FillRectangle(new SolidBrush(fillColor), e.ClipRectangle);

but the glass effect does not appear:


If i ignore the quoted MSDN topic, and instead use fully opaque black (rather than a completely transparent black):

Color fillColor = Color.FromArgb(255, 0, 0, 0); //(a, r, g, b)
e.Graphics.FillRectangle(new SolidBrush(fillColor), e.ClipRectangle);

the glass effect does appear:

i am then lead to believe that opaque black is the pixel value that the DWM will look for to replace with glass.

But then how do i paint black items on the glass area?


i've tested painting a black rectangle on the glass area, with a circle next to it. Oddly enough, the rectangle doesn't appear, while the circle does appear; both are the same color:

Brush b = new SolidBrush(Color.FromArgb(255, 0, 0, 0));
e.Graphics.FillRectangle(b, 11, 11, 32, 32);
e.Graphcis.FillEllipse(b, 43, 11, 32, 32);

So what in the world is going on? What is the proper color to paint in the extended frame area to make glass appear?


Update 2

Using Adisak's suggestion to isolate exactly where the stupidness of Aero lives, here i draw a black rectangle inside the black circle:

Does FillEllipse not support drawing black circles?


Update 3

Pondidum wondered if calling Graphics.Clear with a transparent black color would make the glass visible:

e.Graphics.Clear(Color.FromArgb(0,0,0,0));

It does work, but you still can't draw opaque black items on the glass:


Update 4

Looking at Microsoft's Vista Bridge Library (managed wrappers around Vista functionality that won't be added to .NET), they only ever manage to get extended glass frame working on WPF forms, not WinForms.

See also

解决方案

One of the blog posts that you linked to above has a discussion about this. The native solution was to use SetLayeredWindowAttributes to switch the color key away from black.

这篇关于Windows Aero:涂什么颜色才能制成“玻璃”?出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:19