Search code examples
c#wpfflashactivextransparency

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: <ax:AxShockwaveFlash x:Name="axFlash"/>

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

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.


Solution

  • I believe that it is not possible to do what i want to do... I ended up creating square windows on XP to avoid any transparency related visual issues.