在wpf中需要用到flash播放swf或者圖片,需要使用
AxShockwaveFlashObjects.dll和ShockwaveFlashObjects.dll
在項目中使用的時候遇到
問題1.使用WindowsFormsHost總是置頂的問題,到目前爲止沒有很好的解決
問題2.就是AxShockwaveFlash取消鼠標右鍵
屏蔽掉flash右鍵方法:
重寫AxShockwaveFlash
public partial class MyShockwaveFlash : AxShockwaveFlash
{
public event MouseEventHandler MouseRightDown;
public delegate void MouseEventHandler(object sender, System.Windows.Forms.MouseEventArgs e);
private const int WM_LBUTTONDOWN = 0x0201;
private const int WM_RBUTTONDOWN = 0x0204;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_RBUTTONDOWN:
Int16 x = (Int16)m.LParam;
Int16 y = (Int16)((int)m.LParam >> 16);
MouseRightDown(this, new System.Windows.Forms.MouseEventArgs(System.Windows.Forms.MouseButtons.Right, 1, x, y, 0));
break;
}
if (m.Msg == WM_RBUTTONDOWN)
{
return;
}
base.WndProc(ref m);
}
}
然後使用方法如下:
private void MediaElementControl()
{
FlashPlayer = new MyShockwaveFlash();
wfhFlash.Child = FlashPlayer;
FlashPlayer.Movie = AppDomain.CurrentDomain.BaseDirectory + "main.swf";
FlashPlayer.MouseRightDown += new MyShockwaveFlash.MouseEventHandler(FlashPlayer_MouseRightDown);
}
void FlashPlayer_MouseRightDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
//這裏您可以加入自己的處理或者其他您想處理的代碼//System.Windows.MessageBox.Show("asfasdfasdf");
return;
}
最後問題2 順利得以解決,但是對於問題1目前還沒有找到很好的解決方法,哪位朋友如果有解決方法或者思路歡迎討論交流或者留言均可,謝謝。