在以前,我在防止这方面的工作,当文本框获得焦点时,给他处理剪贴板数据,让其清空。
以下这个代码可不时上面的方法哦,
以下代码在窗体
程序代码: | [ 复制代码 ] |
Option Explicit
’石陆软件屋
’http://www.cnng.net
Private Sub Form_Load()
g_hOldProc = SetWindowLong(Text1.hwnd, GWL_WNDPROC, AddressOf WndProc)
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Text1.hwnd, GWL_WNDPROC, g_hOldProc
End Sub
’石陆软件屋
’http://www.cnng.net
Private Sub Form_Load()
g_hOldProc = SetWindowLong(Text1.hwnd, GWL_WNDPROC, AddressOf WndProc)
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Text1.hwnd, GWL_WNDPROC, g_hOldProc
End Sub
以下代码在模块
程序代码: | [ 复制代码 ] |
Option Explicit
’石陆软件屋
Public 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 Long
Public Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC As Long = -4
Public Const WM_PASTE As Long = &H302
Public g_hOldProc As Long
Public 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
’石陆软件屋
Public 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 Long
Public Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC As Long = -4
Public Const WM_PASTE As Long = &H302
Public g_hOldProc As Long
Public 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
[本日志由 admin 于 2013-11-01 10:55 PM 编辑]
引用通告地址 (0):
http://www.cnng.net/blog/trackback.asp?tbID=50
http://www.cnng.net/blog/trackback.asp?tbID=50&CP=GBK
http://www.cnng.net/blog/trackback.asp?tbID=50
http://www.cnng.net/blog/trackback.asp?tbID=50&CP=GBK