- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在启用 Aero Glass 的情况下使用 DwmExtendFrameIntoClientArea
API 调用效果很好。但是,我希望它在禁用 Aero Glass 时也能正常工作,就像它在 Windows 控制面板中的工作方式一样:
注意框架如何延伸到客户区,即使 Aero Glass 被禁用?当我在我的应用程序中调用 DwmExtendFrameIntoClientArea
API 时,返回的 HRESULT 绝对不成功,我的应用程序最终看起来像这样:
http://img197.imageshack.us/img197/9629/clientapplication.png
通常情况下,启用 Aero Glass 后,边框会向下延伸到导航按钮下方,就像在控制面板中一样。我该怎么做呢? DwmExtendFrameIntoClientArea
显然不起作用。
顺便说一下,如果相关的话,我的应用程序是一个 WPF 应用程序。
最佳答案
Nir 的回答是正确的;当合成被禁用时,你必须自己绘制那个区域。
我可以向您展示我在表单顶部面板的绘制处理程序中的代码 - 该面板通常负责绘制 0x00000000 透明黑色以使玻璃出现:
procedure DrawGlassHeaderArea(g: Graphics; r: Rectangle; IsFormFocused: Boolean);
const
clFakeGlassColor = $00EAD1B9; //(185, 209, 234) This is the fake foreground glass color (for use when composition is disabled)
clFakeGlassColorUnfocused = $00F2E4D7; //(215, 228, 242) This is the fake background glass color (for use when composition is disabled)
begin
if Dwm.IsCompositionEnabled then
begin
g.FillRectangle(r, 0x00000000); //fill rectangle with transparent black
end
else
//Composition disabled; fake it like Microsoft does
//The color to use depends if the form has focused or not
Color glassColor;
if (IsFormFocused) then
c = clFakeGlassColor
else
c = clFakeGlassColorUnfocused;
g.FillRectangle(r, glassColor); //fill rectangle with fake color
//Now we have to draw the two accent lines along the bottom
Color edgeHighlight = ColorBlend(Colors.White, glassColor, 0.33); //mix 33% of glass color to white
Color edgeShadow = ColorBlend(Colors.Black, glassColor, 0.33); //mix 33% of glass color to black
//Draw highlight as 2nd-last row:
g.DrawLine(edgeHighlight, Point(r.Left, r.Bottom-2), Point(r.Right, r.Bottom-2);
//Draw shadow on the very last row:
g.DrawLine(edgeHighlight, Point(r.Left, r.Bottom-1), Point(r.Right, r.Bottom-1);
end;
end;
procedure MyForm.PaintBox1Paint(PaintEventArgs e)
begin
DrawGlassHeaderArea(e.Graphics, PaintBox1.ClientRectangle, this.HasFocus);
end;
@JakePetroules 是对的,我错了。用于假玻璃的“蓝色”未硬编码到 Windows 中。它可以使用 GetThemeColor
访问.
我编写了可用于 Window 类的所有可用颜色 (TMT_COLOR
):
Note: For more information about Classes, Parts, and States, see Aero Style Classes, Parts, and States
使用时:
窗口
WP_CAPTION
并获取颜色代码propertyID:
TMT_FILLCOLORHINT
:当窗口有焦点时TMT_BORDERCOLORHINT
:当窗口没有焦点时你得到了两种重要的颜色:
我现在用来获取假玻璃颜色的伪代码:
public Color GetFakeClassColor(Boolean isWindowFocused=true)
{
static Color fakeGlass= 0x00B8D0E9; //the correct answer anyway
if ((GetThemeAppProperties() && STAP_ALLOW_CONTROLS) == 0)
return fakeGlass;
hTheme = OpenThemeData(GetDesktopWindow(), "Window");
if (hTheme = 0)
return fakeGlass;
Int32 propID;
if (isWindowFocused)
propID= TMT_FILLCOLORHINT; //The color used as a fill color hint for custom controls.
else
propID= TMT_BORDERCOLORHINT; //The color used as a border color hint for custom controls.
DWORD rgb;
if (Failed(GetThemeColor(hTheme, WP_CAPTION, 0, propID, ref rgb))
return fakeGlass;
Result = new Color(rgb);
}
实际上,因为我使用 Delphi,所以我的实际代码是:
function GetFakeGlassColor(IsWindowFocused: Boolean=True): TColor;
var
ted: TThemedElement;
hTheme: THandle;
propID: Integer;
rgb: DWORD;
begin
Result := $00B8D0E9; //the correct answer anyway
//We can't use the ThemeServcies.ThemesEnabled, as that mistakenly checks for version 6 of the common controls library
//Themes can be enabled without using ComCtl V6, or common controls at all
if not ThemeServices.ThemesAvailable then
Exit;
if (GetThemeAppProperties and STAP_ALLOW_CONTROLS) = 0 then
Exit;
htheme := ThemeServices.Theme[teWindow];
if hTheme = 0 then
Exit;
if IsWindowFocused then
propID := TMT_FILLCOLORHINT //The color used as a fill color hint for custom controls.
else
propID := TMT_BORDERCOLORHINT; //The color used as a border color hint for custom controls.
if Failed(GetThemeColor(hTheme, WP_CAPTION, 0, propID, {var}rgb)) then
Exit;
Result := rgb;
end;
关于c# - 没有 Aero Glass 的 DwmExtendFrameIntoClientArea,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2235845/
我对WTL很陌生这是我的主对话框的 onCreate 代码 int Cwin32_mfcDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (C
正如我们所知,一些现代应用程序(IE9、Firefox 4、Chrome、Paint.NET 等)使用 DwmExtendFrameIntoClientArea 来实现 Aero 玻璃效果。 不过,您
在窗口上调用 DwmExtendFrameIntoClientArea 后,如何在保持 Aero 模式的同时再次关闭它? 我尝试调用 DwmExtendFrameIntoClientArea 并将所有
我在使用 DwmExtendFrameIntoClientArea 扩展窗框时遇到了一些麻烦在 Windows 10 上。下图显示了我得到的行为: 白色标题栏颜色从顶部延伸,而从侧面和底部延伸到窗口的
在启用 Aero Glass 的情况下使用 DwmExtendFrameIntoClientArea API 调用效果很好。但是,我希望它在禁用 Aero Glass 时也能正常工作,就像它在 Win
我一直在关注 MSDN's guide to using the DWM API to extend the frame into the client area ,但重做了,这样我就可以在我有一些工
我是一名优秀的程序员,十分优秀!