2008-09-15 93 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; 
相關問題