0

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

4

2 回答 2

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;
    }
于 2013-05-31T08:55:23.053 回答
0

这可以给你一个 RightClick Disabled ShockWaveObject “只有 4 个简单的步骤”

在您的“表单”上添加一个 Shockwave Flash 控件。

1.新建一个名为“NoRightClickFlashControl.vb”的Class文件

将下面的代码粘贴到 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 的名称“AxShockwaveFlash1”更改为“NoRightClickFlashControl1”

打开您的 Form.Designer.vb 文件

3. 更改“Initialize 和 SuspendLayout” 之间的代码,如下所示:

    Private Sub InitializeComponent()

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

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

    Me.SuspendLayout()

然后最后,在“结束类”文件附近的 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运行!享受!!!

于 2014-11-09T17:18:09.327 回答