vb.net消息处理函数 vb中消息框函数( 二 )


在计算 12 月 31 日和来年的 1 月 1 日的年份差时,DateDiff 返回 1 表示相差一个年份,虽然实际上只相差一天而已 。
VB怎么实现滚动条对鼠标中轴的响应?。?/h2>VB可以使用子类化处理鼠标滚轮消息 。
新建工程
在窗体中添加滚动条VScroll1
'窗体代码
Private Sub Form_Load()
'取得控件的句柄
hwndVS = VScroll1.hwnd
'保存smMap控件的默认窗口消息处理函数地址
OldWindowProc = GetWindowLong(VScroll1.hwnd, GWL_WNDPROC)
'将smMap控件的消息处理函数指定为自定义函数NewWindowProc
Call SetWindowLong(VScroll1.hwnd, GWL_WNDPROC, AddressOf NewWindowProc)
End Sub
添加一模块:
Option Explicit
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 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 Const GWL_WNDPROC = -4
Public Const WM_MOUSEWHEEL = H20A
Public OldWindowProc As Long '用来保存系统默认的窗口消息处理函数的地址
Public hwndVS As Long'用来保存控件的句柄
'自定义的消息处理函数
Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
If msg = WM_MOUSEWHEEL Then
'则对鼠标滚轮事件进行处理
If wParam = -7864320 Then '向下滚动
Form1.VScroll1.Value = https://www.04ip.com/post/Form1.VScroll1.Value + 1
ElseIf wParam = 7864320 Then '向上滚动
Form1.VScroll1.Value = https://www.04ip.com/post/Form1.VScroll1.Value - 1
End If
Else
'调用默认窗口消息处理函数
NewWindowProc = CallWindowProc(OldWindowProc, hwnd, msg, wParam, lParam)
End If
End Function
【vb.net消息处理函数 vb中消息框函数】关于vb.net消息处理函数和vb中消息框函数的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读