text控件怎么限制右键复制粘贴输入谢谢。。

解决方案 »

  1.   

    private sub text1_mousedown(botton as integer, ......)
        if button and vbrightbutton then
            text1.enabled=false
            PopupMenu 你自己的弹出菜单
            text1.enabled=true
        end if
    end sub
      

  2.   

    另外,不要忘了还要让ctrl+V失效。
      

  3.   

    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
      If KeyCode = vbKeyV And (Shift And 2) Then
        Text1.Locked = True
      End If
    End SubPrivate Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
        Text1.Locked = False
    End Sub
      

  4.   

    同意在文本框中判断mousedown事件。。
      

  5.   

    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
        If Shift = 2 And (KeyCode = 67 Or KeyCode = 86) Then StopCopy Text1
    End SubPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 2 Then StopCopy Text1
    End SubSub StopCopy(obj As TextBox)
        Dim P As Long
        Clipboard.Clear
        P = obj.SelStart
        If Len(obj.SelText) Then obj.SelStart = P
    End Sub
      

  6.   

    Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then If Len(Text1.SelText) Then Text1.SelStart = 0
    Clipboard.Clear
    End Sub
      

  7.   

    'in form1
    Option ExplicitPrivate Sub Form_Load()
        g_hOldProc = SetWindowLong(Text1.hwnd, GWL_WNDPROC, AddressOf WndProc)
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        SetWindowLong Text1.hwnd, GWL_WNDPROC, g_hOldProc
    End Sub
    'in module1
    Option ExplicitPublic Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPublic Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic Const GWL_WNDPROC As Long = -4Public Const WM_PASTE As Long = &H302Public g_hOldProc As LongPublic Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        If uMsg = WM_PASTE Then
            WndProc = 0
        Else
            WndProc = CallWindowProc(g_hOldProc, hwnd, uMsg, wParam, lParam)
        End If
    End Function