不带 Aero Glass 的 DwmExtendFrameIntoClientArea
在启用 Aero Glass 的情况下使用 DwmExtendFrameIntoClientArea
API 调用效果很好。但是,我希望它在 Aero Glass 被禁用时也能工作,就像它在 Windows 控制面板中的工作方式一样:
请注意,即使 Aero Glass 已禁用,框架仍如何延伸到客户区域?当我在应用程序中进行 DwmExtendFrameIntoClientArea
API 调用时,返回的 HRESULT 肯定不成功,我的应用程序最终看起来像这样:
http://img197.imageshack.us/img197/9629/clientapplication.png
通常,启用 Aero Glass 后,边框会向下延伸到导航按钮下方,就像控制面板。我该怎么做? DwmExtendFrameIntoClientArea
显然不起作用。
顺便说一下,如果相关的话,我的应用程序是WPF应用程序。
Using the DwmExtendFrameIntoClientArea
API call with Aero Glass enabled works just fine. However, I want it to work when Aero Glass is disabled as well, like how it works in the Windows control panel:
Notice how the frame has extended into the client area, even though Aero Glass is disabled? When I make the DwmExtendFrameIntoClientArea
API call in my application, the returned HRESULT is definitely not success, and my application ends up looking like this:
http://img197.imageshack.us/img197/9629/clientapplication.png
Normally, with Aero Glass enabled, the border stretches down to underneath the navigation buttons, like in the control panel. How do I do this? DwmExtendFrameIntoClientArea
clearly isn't working.
By the way, if it is relevant, my application is a WPF application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尼尔的回答是正确的;当构图被禁用时,您必须自己绘制该区域。
我可以向您展示表单顶部面板的绘制处理程序中的代码 - 该面板通常负责绘制 0x00000000 透明黑色以使玻璃出现:
伪代码:
示例使用
奖励屏幕截图
更新 7/9/2014
@JakePetroules 是对的,而我错了。用于假玻璃的“蓝色”未硬编码到Windows中。并且可以使用
GetThemeColor
。我编码了可用于 Window 类的所有可用颜色 (
TMT_COLOR
):使用时:
Window< /code>
WP_CAPTION
并获取颜色代码propertyID:
TMT_FILLCOLORHINT
:当窗口具有焦点时TMT_BORDERCOLORHINT
:当窗口没有焦点时,您将获得两种重要的颜色:
我现在用来获取假玻璃颜色的伪代码:
实际上,由于我使用 Delphi,我的实际代码是:
Nir's answer is correct; when composition is disabled you have to draw that area yourself.
i can show you the code i have in the paint handler of the panel at the top of my form - the panel normally responsible for drawing the 0x00000000 transparent black to make the glass appear:
Psuedo-code:
Sample usage
Bonus Screenshot
Update 7/9/2014
@JakePetroules was right, and i was wrong. The "blue" used for fake glass is not hard-coded into Windows. And it is accessible using
GetThemeColor
.I coded up all the available colors (
TMT_COLOR
) available for a Window class:When using:
Window
WP_CAPTION
and fetch the color code propertyID:
TMT_FILLCOLORHINT
: for when the window has focusTMT_BORDERCOLORHINT
: for when the window does not have focusyou get the two important colors:
The pseudo-code i now use to get the fake glass color:
In reality, since i use Delphi, my actual code is:
你必须把它画成你自己的框架。
您必须使用
DwmIsCompositionEnabled
来检查 DWM 是否已启用,并处理WM_DWMCOMPOSITIONCHANGED
来检测 DWM 状态更改。然后你必须以单独的方式绘制窗口,如果启用了 DWM,则使用 DwmExtendFrameIntoClientArea,如果禁用,则自己绘制“框架”。
我不知道如何在 WPF 中复制 Aero 框架(在我的应用程序中,我有自己的配色方案,并且没有使用 Auro 框架)。
这很烦人,但是当 DWM 被禁用时,系统会回退到 XP 样式绘图,并且 DWM 的任何服务都不起作用 - 即使是那些与玻璃效果无关的服务。
You have to paint it to be frame-like yourself.
You have to use
DwmIsCompositionEnabled
to check if the DWM is enabled and handleWM_DWMCOMPOSITIONCHANGED
to detect DWM state changed.Then you have to have to separate way of drawing the window, if DWM is enabled you use
DwmExtendFrameIntoClientArea
, if it's disabled you draw the "frame" yourself.I have no idea how to duplicate the Aero frame in WPF (in my app I have my own color scheme and I'm not using the Auro frame).
This is annoying but when the DWM is disabled the system falls back to XP-style drawing and none of the DWM's services work - even those that aren't related to the glass effect.
您需要自己绘制窗口背景。您实际上不应该像以前的帖子所建议的那样对颜色进行硬编码,而是使用主题函数来检索它们,如下所示(半伪代码):
即使用户在控制面板中更改标题栏颜色,这些颜色也将保持正确(与使用 COLOR_ACTIVECAPTION / COLOR_GRADIENTACTIVECAPTION 不同)。在尝试获取主题颜色之前,您还应该使用
IsThemeActive()
检查主题是否处于活动状态。供快速参考的常量值:
You need to paint the window background yourself. You should not actually hard-code the colors as previous posts have suggested, but use the theme functions to retrieve them, like so (semi-pseudocode):
These colors will remain correct even if the user changes title bar colors in the control panel (unlike using COLOR_ACTIVECAPTION / COLOR_GRADIENTACTIVECAPTION). You should also check that themes are active using
IsThemeActive()
before attempting to get theme colors.The values of the constants for quick reference: