Chinaunix首页 | 论坛 | 博客
  • 博客访问: 35205
  • 博文数量: 55
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 500
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-23 14:08
文章分类

全部博文(55)

文章存档

2024年(11)

2023年(22)

2022年(22)

我的朋友

分类: Windows平台

2022-11-08 12:48:37

vb mshflexgrid支持鼠标滑轮

1、建标准模块
  '''=========放标准模块================
Option Explicit
'Download by
'支持滚轮鼠标API---------------------------------
Public Const GWL_WNDPROC = (-4)
Public Const WM_COMMAND = &H111
Public Const WM_MBUTTONDOWN = &H207
Public Const WM_MBUTTONUP = &H208
Public Const WM_MOUSEWHEEL = &H20A


Public Oldwinproc 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 Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long _
) As Long


Public Function FlexScroll(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'支持滚轮的滚动
Select Case wMsg
Case WM_MOUSEWHEEL
Select Case wParam
Case -7864320 '向下滚
SendKeys "{PGDN}"
Case 7864320 '向上滚
SendKeys "{PGUP}"
End Select
End Select
FlexScroll = CallWindowProc(Oldwinproc, hWnd, wMsg, wParam, lParam)
End Function
  '''=========放标准模块================


 '''====MSHFLEXGRID=====================
Private Sub MSHFlexGrid1_GotFocus()
Oldwinproc = GetWindowLong(Me.hWnd, GWL_WNDPROC)
SetWindowLong Me.hWnd, GWL_WNDPROC, AddressOf FlexScroll
End Sub


Private Sub MSHFlexGrid1_LostFocus()
SetWindowLong Me.hWnd, GWL_WNDPROC, Oldwinproc
End Sub


 '''====MSHFLEXGRID=====================
阅读(742) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~