DwmExtendFrameIntoClientArea没有Aero玻璃

编程入门 行业动态 更新时间:2024-10-20 05:39:58
本文介绍了DwmExtendFrameIntoClientArea没有Aero玻璃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用 DwmExtendFrameIntoClientArea API调用与Aero玻璃启用的作品就好了。不过,我想它的工作时,Aero玻璃被禁用,以及像它是如何工作在Windows控制面板:

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:

请注意框架已经扩展到客户区,尽管Aero玻璃被禁用?当我把我的应用程序的 DwmExtendFrameIntoClientArea API调用返回的HRESULT是绝对不会成功,我的应用程序最终看起来是这样的:

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:

通常情况下,用Aero玻璃启用,边界延伸到导航按钮下方,像中控面板。我该怎么做呢? DwmExtendFrameIntoClientArea 显然是行不通的。

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.

顺便说一句,如果是相关的,我的应用程序是一个WPF应用程序。

By the way, if it is relevant, my application is a WPF application.

推荐答案

尼尔的答案是正确的;当成分被禁用,你必须自己绘制的区域。

Nir's answer is correct; when composition is disabled you have to draw that area yourself.

我可以告诉你的$ C $词已经在面板的我的窗体顶部的油漆处理程序 - 面板通常负责绘制00000000透明的黑色使玻璃出现:

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:

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;

红利截图

Bonus Screenshot

@JakePetroules是对的,我错了。在蓝的用于假冒玻璃的不可以硬codeD到Windows。它的是访问使用的 GetThemeColor 。

@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了所有可用的颜色( TMT_COLOR )可用于窗口类:

I coded up all the available colors (TMT_COLOR) available for a Window class:

注意:有关类,部件的详细信息,以及各国,看到的 的Aero样式类,部件和美国

Note: For more information about Classes, Parts, and States, see Aero Style Classes, Parts, and States

在使用:

  • 类:窗口
  • 第: WP_CAPTION
  • 国家: N / A(STATEID不用于在标题的一部分,也不是所有的窗口班)
  • Class: Window
  • Part: WP_CAPTION
  • State: n/a (StateID is not used for the Caption part, nor the entire Window class)

和取色code 属性ID

  • TMT_FILLCOLORHINT :因为当窗口集中
  • TMT_BORDERCOLORHINT :为当窗口没有焦点

你得到的两个重要的颜色:

you get the two important colors:

伪$ C $词现在用它来获得假的玻璃颜色:

The pseudo-code i now use to get the fake glass color:

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); }

在现实中,由于我使用德尔福,我的实际code是:

In reality, since i use Delp my actual code is:

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;

更多推荐

DwmExtendFrameIntoClientArea没有Aero玻璃

本文发布于:2023-11-12 03:58:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580452.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:玻璃   DwmExtendFrameIntoClientArea   Aero

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!