【问题标题】:SetLayeredWindowAttributes not working on Windows 7SetLayeredWindowAttributes 在 Windows 7 上不起作用
【发布时间】:2010-10-19 09:31:54
【问题描述】:

我正在使用 SetLayeredWindowAttributer 使分层窗口的特定颜色透明。

这在 Windows XP,VISTA 上运行良好。但是当我在 Windows 7 上使用它时它不起作用。

SetLayeredWindowAttributes(hWnd, RGB(0xff,0xff,0xff), 0, LWA_COLORKEY);

当我使用 LWA_ALPHA 时,它也可以工作。 问题是我无法在 Windows 7 中使特定颜色透明。

以下语句适用于 Windows 7

SetLayeredWindowAttributes(hWnd,RGB(0xff,0xff,0xff), 100, LWA_ALPHA);

有没有可能是渲染出来的颜色值与SetLayeredWindowAttributes中的颜色值不匹配?

【问题讨论】:

    标签: c++ winapi windows-7 transparency


    【解决方案1】:

    您应该避免将 0xff、0xff、0xff(白色)与 LWA_COLORKEY 一起使用。任何其他值都可以(例如 0xff,0xff,0xfe)。

    为了更好地控制分层窗口,我建议您考虑使用 UpdateLayeredWindowIndirect。我写了一篇文章,详细描述了它如何与 GDI 和 Direct2D 一起使用。

    http://msdn.microsoft.com/en-us/magazine/ee819134.aspx

    【讨论】:

      猜你喜欢
      • 2012-06-13
      • 1970-01-01
      • 2018-06-27
      • 1970-01-01
      • 2017-04-26
      • 1970-01-01
      • 2011-02-19
      • 2014-01-17
      相关资源
      最近更新 更多