【问题标题】:How to make WPF UserControl transparent if it is a child window of a GDI+ application?如果 WPF UserControl 是 GDI+ 应用程序的子窗口,如何使 WPF UserControl 透明?
【发布时间】:2013-02-18 03:10:36
【问题描述】:

我是桌面开发的初学者。我将 WPF UserControl 添加为带有 HwndSource 的 GDI+ 本机 C++ 应用程序的子窗口,但我的 UserControl 的背景不透明(它是透明的,因为我在纯 WPF 应用程序中使用此 UserControl)。无论我将其设置为空还是透明,它都会呈现为不透明的黑色。有什么方法可以使我的 WPF UserControl 的背景透明吗?我的选择是什么?

【问题讨论】:

  • 请贴一些代码。

标签: wpf transparency gdi+


【解决方案1】:

UsesPerPixelOpacity = true;来自 HwndSourceParameters 已经解决了这个问题。 还需要设置窗口样式标志:

    p.WindowStyle = (int)0x94000C00;
    p.ExtendedWindowStyle = 0x00080088;

【讨论】:

    猜你喜欢
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-15
    相关资源
    最近更新 更多