VB.NET禁用右键单击AxShockwaveFlash元素

时间:2013-03-16 20:20:53

标签: vb.net visual-studio-2010 visual-studio axshockwaveflash

我试图在我的应用程序中禁用shockwave flash元素的内置右键菜单,但它不起作用。有没有办法在VB中禁用它?谢谢!

2 个答案:

答案 0 :(得分:1)

它应禁用鼠标右键单击事件:

public partial class Form1 : Form ,IMessageFilter // after the name space
{     

     private const int WM_LBUTTONDOWN = 0x0201;



    public Form1()
    {
        InitializeComponent();
        Application.AddMessageFilter(this);
        this.FormClosed += new FormClosedEventHandler(this.Form1_FormClosed);
    }
    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
        Application.RemoveMessageFilter(this);
    }
    public bool PreFilterMessage(ref Message m)
    {
         //Filter out WM_NCRBUTTONDOWN/UP/DBLCLK
        if (m.Msg == 0xA4 || m.Msg == 0xA5 || m.Msg == 0xA6) return true;
        // Filter out WM_RBUTTONDOWN/UP/DBLCLK
        if (m.Msg == 0x204 || m.Msg == 0x205 || m.Msg == 0x206) return true;
        return false;
    }

答案 1 :(得分:0)

这可以给你一个RightClick已禁用的ShockWaveObject"只有4个简单的步骤"

在你的" Form"添加一个Shockwave Flash控件。

<强> 1。创建一个名为&#34; NoRightClickFlashControl.vb&#34;

的新类文件

将波纹管代码粘贴到NoRightClickFlashControl.vb中

Public Class NoRightClickFlashControl

Inherits AxShockwaveFlashObjects.AxShockwaveFlash
Private Const WM_RBUTTONDOWN As Integer = &H204

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    Select Case m.Msg
        Case WM_RBUTTONDOWN
            ' Do nothing on right-click
            m.Result = New IntPtr(1)
            Return
    End Select
    MyBase.WndProc(m)
End Sub

End Class

<强> 2。更改ShockwaveObject的名称&#34; AxShockwaveFlash1&#34;表格上的到&#34; NoRightClickFlashControl1&#34;

打开您的Form.Designer.vb文件

第3。在&#39; Initialize和SuspendLayout&#39; 之间更改代码,如下所示:

    Private Sub InitializeComponent()

'// Old is : Me.NoRightClickFlashControl1 = New AxShockwaveFlashObjects.AxShockwaveFlash()

    '// Change like this
    Me.NoRightClickFlashControl1 = New Your_Project_NameSpace.NoRightClickFlashControl

    Me.SuspendLayout()

然后在最后,在&#34; End Class&#34;附近的Form.Designer.vb中;文件 - 更改以下内容

'// Old is : Friend WithEvents NoRightClickFlashControl1 As AxShockwaveFlashObjects.AxShockwaveFlash

  '// Change Like this :
  Friend WithEvents NoRightClickFlashControl1 As NoRightClickFlashControl

End Class '// the End Class is just o understand.

所有其他编码与ShockwaveFlashObject相同 - 加载电影,播放

完成

按F5运行!享受!!!