2011-02-08 12 views
2

私のプロジェクトでは、右クリックを無効にするAXShockwaveFlashコントロールをオーバーライドしています。次のコードを使用して管理できます。.NET WebBrowserをオーバーライドするWndProc

public class FlashPlayer : AxShockwaveFlashObjects.AxShockwaveFlash 
{ 
    private const int WM_MOUSEMOVE = 0x0200; 
    private const int WM_MOUSEWHEEL = 0x020A; 
    private const int WM_LBUTTONDOWN = 0x0201; 
    private const int WM_LBUTTONUP = 0x0202; 
    private const int WM_LBUTTONDBLCLK = 0x0203; 
    private const int WM_RBUTTONDOWN = 0x0204; 
    private const int WM_RBUTTONUP = 0x0205;      

    public new event MouseEventHandler DoubleClick; 

    public new event MouseEventHandler MouseDown; 

    public new event MouseEventHandler MouseUp; 

    public new event MouseEventHandler MouseMove; 

    public FlashPlayer() 
    { 
     this.HandleCreated += FlashPlayer_HandleCreated; // listen for the HandleCreated event. 
    } 

    void FlashPlayer_HandleCreated(object sender, EventArgs e) // make required configuration changes. 
    { 
     this.AllowFullScreen = "true"; 
     this.AllowNetworking = "all"; 
     this.AllowScriptAccess = "always"; 
    } 

    protected override void WndProc(ref Message m) // Override's the WndProc and disables Flash activex's default right-click menu and if one exists shows the attached ContextMenuStrip. 
    { 
     switch (m.Msg) 
     { 
      case WM_LBUTTONDOWN: 
       if (this.MouseDown != null) this.MouseDown(this, new MouseEventArgs(MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0)); 
       break; 
      case WM_LBUTTONUP: 
       if (this.MouseUp != null) this.MouseUp(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); 
       break; 
      case WM_MOUSEMOVE: 
       if (this.MouseMove != null) this.MouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); 
       break; 
      case WM_RBUTTONDOWN: 
       if (this.ContextMenuStrip != null) this.ContextMenuStrip.Show(Cursor.Position.X, Cursor.Position.Y); 
       m.Result = IntPtr.Zero; // don't allow actual flash control process the message by flagging it as processed. 
       return; 
      case WM_LBUTTONDBLCLK: 
       if (this.DoubleClick != null) this.DoubleClick(this, new MouseEventArgs(MouseButtons.Left, 2, Cursor.Position.X, Cursor.Position.Y, 0)); 
       m.Result = IntPtr.Zero; // don't allow actual flash control process the message by flagging it as processed. 
       return; 
     } 

     base.WndProc(ref m); // when we're done with processing the events, let the message pass to others also too. 
    } 
} 

私はまた、WebBrowserコントロールのコードを使用しようとしているが、WebブラウザーのWndProcメソッドに私のクリックイベントは全く捕捉されません。

アイデア?

更新:私は無効にされて何をしようとしているWebブラウザ上で完全に右クリックし、IsWebBrowserContextMenuEnabledは、Webブラウザでのフラッシュコンポーネントはまだ右クリックを処理するための私の状態で作業し、レンダリングされません。それは自分のメニューです。

+2

もう一度右クリックを無効にしてください。何を実装しますか? – abatishchev

+1

ご迷惑をおかけして申し訳ございませんが、ここでのUIの決定についてはお伝えしません。基本的には、自分の右クリックメニューです。ボーダレスフォーム、チャットルームなどの機能を映画の再生に使用できます。 – HuseyinUslu

答えて

2

をFlashウィンドウにリダイレクトされます。 Flash Playerをウィンドウレスにする(wmodeパラメータだと思います)、そうでなければ、Webブラウザーの子ウィンドウを列挙してコントロールを見つけ、それをサブクラス化する必要があります。

+0

ありがとう私はこれを試してみましょう。 – HuseyinUslu

0

私はこのスレッドでは少し複雑溶液(そう、私を責めないでください)が見つかりました:私は、問題はWebブラウザーがメッセージので、メッセージを受信して​​いないことであると思い、あなたの更新により social.msdn.microsoft.com/forums...

+0

私はネイティブのフラッシュコントロールを右クリックすることを無効にするためにこのメソッドを実装していますが、私が言及しているフラッシュコントロールはwebbrowserコントロールに埋め込まれています。 – HuseyinUslu

関連する問題