2008-09-15 94 views

回答

2

除非用于显示Flash内容的控件是在WPF中构建的,否则您将遇到这些“空域”问题。从Win32到WinForms的每种显示技术都使用HWND“隐藏”,但WPF使用DirectX。然而Windows中的窗口管理器仍然只能理解HWND,所以WPF应用程序有一个基于HWND的顶层窗口,并且所有这些都是在DirectX中完成的(实际上,上下文菜单和工具提示也具有顶级HWND) 。 Adam Nathan对WPF的互操作有很好的描述,在this article

0

您可以使用Expression将Flash内容转换为XAML吗?我相信在那里有或没有工具可以做到这一点。

1

尽管我没有这样做,但您可以使用WPF 3.5 sp1中的WebBrowser控件将您的Flash内容封装到WPF中。我不确定透明度如何受到影响。

+0

对于它的价值:我试过这个,WebBrowser控件很好地托管Flash内容,但是你不能违反上面提到的空域约束。 – 2009-06-05 19:13:05

-1

刚刚一直在努力解决如何上传相同的问题&使WPF透明并具有显示Flash的能力,因为如果您在MainWindow上启用“允许透明度”,Flash将不会在应用程序运行后显示。

1)我用WebBrowser控件播放Flash(.swf)文件。他们在我的电脑上,但是它可以从互联网上播放,也可以在任何地方播放。不要忘了命名您的WebBrowser控件以在C#中实现。

private void Window_Loaded(object sender, RoutedEventArgs e) 
{ 
    MyHelper.ExtendFrame(this, new Thickness(-1));  
    this.MyBrowser.Navigate(@"C:\Happy\Download\flash\PlayWithMEGame.swf");   
} 

2)现在透明度。我已将WPF'false'设置为“Allow Transparency”并将“Window Style”设置为“None”。从那以后,我已经从HEREHERE使用的信息,并创建了生产允许在主窗口的透明度和运行在同一时间的Flash所需效果的下面的代码,这里是我的代码:

public class MyHelper 
{ 
    public static bool ExtendFrame(Window window, Thickness margin) 
    { 
     IntPtr hwnd = new WindowInteropHelper(window).Handle; 
     window.Background = Brushes.Transparent; 
     HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent; 
     MARGINS margins = new MARGINS(margin); 
     DwmExtendFrameIntoClientArea(hwnd, ref margins); 
     return true; 
    } 
    [DllImport("dwmapi.dll", PreserveSig = false)] 
    static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); 
} 

struct MARGINS 
    { 
     public MARGINS(Thickness t) 
     { 
      Left = (int)t.Left; 
      Right = (int)t.Right; 
      Top = (int)t.Top; 
      Bottom = (int)t.Bottom; 
     } 
     public int Left; 
     public int Right; 
     public int Top; 
     public int Bottom; 
    } 

,并称之为从Window_Loaded() +你需要'DllImport'的'下面'行才能工作。

using System.Runtime.InteropServices; 
using System.Windows.Interop; 
相关问题