以下代码在窗体
程序代码: |
Option Explicit
’石陆软件屋
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
以下代码在模块
’石陆软件屋
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
VB部分相关文章推荐