rt

解决方案 »

  1.   

    从CEdit继承,自己设计一个myedit,自己处理 WM_RBUTTONDOWN和WM_RBUTTONUP消息,(直接返回TRUE)  就OK了
      

  2.   

    对不起,没有看到是VB,VB俺没有用过。
      

  3.   

    可以是下面这样
    private sub text1_mousedown(button as integer)
    if button=2 then
      text1.enabled=false
      text1.enabled=true   '这样就隐蔽了菜单,但keydown事件仍可发生
    end if
    end sub
      

  4.   

    Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
      If Button = 2 Then
        Text1.Enabled = False
        Text1.Enabled = True
        Text1.SetFocus
        PopupMenu control   '加入你自己的控件菜单
      End If
    End Sub
      

  5.   

    Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
      MsgBox "norbutton", vbDefaultButton1
    End IfEnd Sub
      

  6.   

    Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
      MsgBox "norbutton"
    End IfEnd Sub
      

  7.   

    ;楼上的还要弹出一个对话框,另用户操作不方便,还是用这个
    Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
      If Button = 2 Then
        Text1.Enabled = False
        Text1.Enabled = True
        Text1.SetFocus
        PopupMenu control   '加入你自己的控件菜单
      End If
    End Sub
      

  8.   

    Option ExplicitPublic Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Public Const GWL_WNDPROC = (-4)Public Const WM_RBUTTONDBLCLK = &H206
    Public Const WM_RBUTTONDOWN = &H204
    Public Const WM_RBUTTONUP = &H205Public prevWndProc As LongPublic Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Select Case Msg
            Case WM_RBUTTONDBLCLK:
            Case WM_RBUTTONDOWN:
            Case WM_RBUTTONUP:
            Case Else
                WndProc = CallWindowProc(prevWndProc, hWnd, Msg, wParam, lParam)
        End Select
    End Function
    -------------------------
    Option ExplicitPrivate Sub Form_Load()
        Me.Show
        prevWndProc = GetWindowLong(Text1.hWnd, GWL_WNDPROC)
        SetWindowLong Text1.hWnd, GWL_WNDPROC, AddressOf WndProc
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        If prevWndProc <> 0 Then
            SetWindowLong Text1.hWnd, GWL_WNDPROC, prevWndProc
            prevWndProc = 0
        End If
    End Sub
    ==================
    上面的代码写入模块,下面的代码写入FORM1。
      

  9.   

    text1.enabled=falsedoeventstext1.enabled=true这些人知道方法,却没有使用过,所以说得似是而非。
      

  10.   

    SetWindowsHookEx  消息拦截  吃掉消息
      

  11.   

    哪有那么复杂
    Option Explicit
    Private Declare Sub ReleaseCapture Lib "user32" ()
    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As LongPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbRightButton Then
            ReleaseCapture
            SetCapture Me.hwnd
        End If
    End Sub
      

  12.   

    不对吧,我把enabled设为false,就不能粘贴了!按右键都没反应。
      

  13.   

    你在设计时就把它设为false,这样就行了。在它下面放置一个别的控件,以响应鼠标事件。比如imagebox。
      

  14.   

    把右键消息去掉
    或者不响应
    这样就可以了
    不要把enable设置为false
    否则不能用Ctrl +V
      

  15.   

    Private Sub Text1_OnMouseDown(...)
        if button = 2 then button = 0
    End Sub
      

  16.   

    Private ClipStr As String '剪切板的内容'禁鼠标右键粘贴
    Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
        If Button = 2 Then SetClip
    End SubPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
        If Button = 2 Then GetClip
    End Sub'禁键盘粘贴
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
        If Shift = 2 And KeyCode = 86 Then '键盘上的CTRL+V 
            KeyCode = 0
            GetClip
        End If
    End SubPrivate Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
        If Shift = 2 And KeyCode = 86 Then
            KeyCode = 0
            SetClip
        End If
    End Sub
    '取剪切板内容
    Private Sub GetClip()
    If Clipboard.GetFormat(1) = True Then
        ClipStr = Clipboard.GetText
        Clipboard.Clear
        End If
    End Sub
    '设剪切板内容
    Private Sub SetClip()
    If ClipStr <> "" And Clipboard.GetText = "" Then
            Clipboard.SetText ClipStr
            ClipStr = ""
        End If
    End Sub
      

  17.   


    放假回来了,看到大家的留言,感谢
    试了大家的方法,总结如下:dongge2000(※秋日私语※:非[版务].灌!) 的方法可行,禁止了右键菜单,同时Ctrl_V可以粘贴Tiger_Zhao(VB老鸟)的方法可以理解,但是不知为何出错laihongbo524(风铃夜思雨)的方法禁止了右键粘贴,但也禁止了Ctrl_V,我把禁键盘那段拿掉,就可以了:)所以也可行其他方法未试成功结贴,非常感谢各位!