WPF Window transparency while hosting a Flash ActiveX component

My application has a custom window design, which means that every window has the following parameters set (XAML): WindowStyle="None" AllowsTransparency="False"

One of the sub windows needs to display a Flash component, the Flash ActiveX component is hosted thrugh XAML:

With regards to window transparency , there is a known issue with WPF and hosted winforms components, it just doesn't work out of the box. In order to be able to view the Flash component, AllowsTransparency must be set to "False", otherwise, the flash component will simply not be displayed.

To maintain the window's transparency (and general L&F), I have modified this piece of code: http://blogs.msdn.com/b/adam_nathan/archive/2006/05/04/589686.aspx

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

So everything is now working great, until I started checking it on XP . Obviously, the above piece of code doesn't work on XP since the DLL used (dwmapi.dll) is a Vista DLL.

The question is whether the same result can be achieved in XP and if so, how?

I've tried altering this piece of code: How to create a semi transparent window in WPF that allows mouse events to pass through or similar other examples, yet, I didn't manage to achieve any window transparency.

Would appreciate any advice.


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

链接地址: http://www.djcxy.com/p/25904.html

上一篇: C#

下一篇: 托管Flash ActiveX组件时的WPF窗口透明度