gpt4 book ai didi

c# - 承载 Flash ActiveX 组件时的 WPF 窗口透明度

转载 作者:行者123 更新时间:2023-11-30 18:07:06 30 4
gpt4 key购买 nike

我的应用程序有一个自定义窗口设计,这意味着每个窗口都有以下参数集 (XAML):WindowStyle="无"AllowsTransparency="假"

其中一个子窗口需要显示一个 Flash 组件,Flash ActiveX 组件通过 XAML 托管:

关于窗口透明度,WPF 和托管的 winforms 组件存在一个已知问题,它无法开箱即用。为了能够查看 Flash 组件,必须将 AllowsTransparency 设置为“False”,否则,Flash 组件将根本不显示。

为了保持窗口的透明度(以及一般的 L&F),我修改了这段代码:Link

        IntPtr hwnd = new WindowInteropHelper(window).Handle;

// Set the background to transparent from both the WPF and Win32 perspectives
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;

MARGINS margins = new MARGINS(margin);
DwmExtendFrameIntoClientArea(hwnd, ref margins);

现在一切正常,直到我开始在 XP 上检查它。显然,上面的代码在 XP 上不起作用,因为使用的 DLL (dwmapi.dll) 是一个 Vista DLL。

问题是在 XP 中是否可以实现相同的结果,如果可以,如何实现?

我试过修改这段代码:How to create a semi transparent window in WPF that allows mouse events to pass through或类似的其他示例,但是,我没有设法实现任何窗口透明度。

如有任何建议,我们将不胜感激。

最佳答案

我认为不可能做我想做的事...我最终在 XP 上创建了方形窗口以避免任何与透明度相关的视觉问题。

关于c# - 承载 Flash ActiveX 组件时的 WPF 窗口透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4253665/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com