'模块代码Public OldWindowProc As Long Public Const WM_CONTEXTMENU = &H7B Public Const GWL_WNDPROC = (-4) 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 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 LongPublic Function MyMesg(ByVal hWnd As OLE_HANDLE, ByVal Msg As OLE_HANDLE, ByVal wp As OLE_HANDLE, ByVal lp As Long) As Long If Msg <> WM_CONTEXTMENU Then MyMesg = CallWindowProc(OldWindowProc, hWnd, Msg, wp, lp) ' Exit Function End If End Function'窗体代码 Private Sub Text2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then OldWindowProc = GetWindowLong(Text2.hWnd, GWL_WNDPROC) Call SetWindowLong(Text2.hWnd, GWL_WNDPROC, AddressOf MyMesg) End If End SubPrivate Sub Text2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then Call SetWindowLong(Text2.hWnd, GWL_WNDPROC, OldWindowProc) End IfEnd SubPrivate Sub Text2_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub
Public Const WM_CONTEXTMENU = &H7B
Public Const GWL_WNDPROC = (-4)
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 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 LongPublic Function MyMesg(ByVal hWnd As OLE_HANDLE, ByVal Msg As OLE_HANDLE, ByVal wp As OLE_HANDLE, ByVal lp As Long) As Long
If Msg <> WM_CONTEXTMENU Then
MyMesg = CallWindowProc(OldWindowProc, hWnd, Msg, wp, lp) '
Exit Function
End If
End Function'窗体代码
Private Sub Text2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
OldWindowProc = GetWindowLong(Text2.hWnd, GWL_WNDPROC)
Call SetWindowLong(Text2.hWnd, GWL_WNDPROC, AddressOf MyMesg)
End If
End SubPrivate Sub Text2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
Call SetWindowLong(Text2.hWnd, GWL_WNDPROC, OldWindowProc)
End IfEnd SubPrivate Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
用label也不行,我放上面的可能是一篇文章,长度不一样,所以用label显示会有一定的问题yunyu97()
放在picturebox上后textbox的滚动条也还是不能用。
textbox的得到焦点的事件中:
form1.setfocus
方法二
不停的清空剪贴版
转移焦点也不行,还是可以选择复制textbox的内容的
谢谢大家!