`

拦截 VB TextBox 双击消息

    博客分类:
  • vb
VB 
阅读更多

我们都知道在VB中TextBox默认是没有双击消息过程的(也就是双击事件,单击事件是有的.),那么看看本文是怎么实现TextBox双击消息的吧。

Option Explicit

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 Long

Public Const
GWL_WNDPROC = (-4)
Public Const WM_NCLBUTTONDBLCLK = &H203 'DoubleClick Message
Public prevWndProc As Long

Public Function
WndProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If
msg = WM_NCLBUTTONDBLCLK Then 'DoubleClick Message
'Eat The Message
Else 'Other Message send to next
WndProc = CallWindowProc(prevWndProc, hwnd, msg, wParam, lParam)
End If
End Function

'*************************************************************************
'**主要函数
'*************************************************************************
Public Sub TxtDoubleClickMassage(Frm As Form)
Dim i As Integer
For
i = 0 To 9 '
'区分符号
prevWndProc = GetWindowLong(Frm.txtKairo(i).hwnd, GWL_WNDPROC)
SetWindowLong Frm.txtKairo(i).hwnd, GWL_WNDPROC,
AddressOf WndProc
'名称1
prevWndProc = GetWindowLong(Frm.txtIkisaki1(i).hwnd, GWL_WNDPROC)
SetWindowLong Frm.txtIkisaki1(i).hwnd, GWL_WNDPROC,
AddressOf WndProc
'名称2
prevWndProc = GetWindowLong(Frm.txtIkisaki2(i).hwnd, GWL_WNDPROC)
SetWindowLong Frm.txtIkisaki2(i).hwnd, GWL_WNDPROC,
AddressOf WndProc
Next
End Sub

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics