标题:如何才能实现通过滚动鼠标滚轮使 MSHFlexGrid 控件 的 行 进行上下移动?
只看楼主
sandyw
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-3-7
得分:0 

哈,佛山兄,你也到这里来了!

2006-03-07 18:44
majiaow
Rank: 1
等 级:新手上路
帖 子:172
专家分:0
注 册:2006-2-21
得分:0 
想來學一手,頂

2006-03-09 08:27
skdyu
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2007-3-26
得分:0 
凡我搜到的例子, 都试过,不行 .谢谢!!!!
2007-10-10 19:02
simpson
Rank: 3Rank: 3
等 级:论坛游民
威 望:7
帖 子:863
专家分:17
注 册:2006-11-16
得分:0 

绝对能用

module:

Public Const GWL_WNDPROC = -4&
Public Const WM_COPYDATA = &H4A
Public Const WM_MOUSEWHEEL = &H20A
Public Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As Long
End Type
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 Sub RtlMoveMemory Lib "kernel32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Public prevWndProc As Long

Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long,
ByVal yPoint 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 Type POINTAPI
X As Long
Y As Long
End Type
Public OldWindowProc As Long ???
Public hwndDataGrid 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
Dim CurPoint As POINTAPI, hwndUnderCursor As Long
GetCursorPos CurPoint
hwndUnderCursor = WindowFromPoint(CurPoint.X, CurPoint.Y)
If wParam = -7864320 Then
frmEquipManage.DataGrid1.Scroll frmEquipManage.DataGrid1.VisibleCols, frmEquipManage.DataGrid1.VisibleRows
ElseIf wParam = 7864320 Then
frmEquipManage.DataGrid1.Scroll -frmEquipManage.DataGrid1.VisibleCols, -frmEquipManage.DataGrid1.VisibleRows
End If
Else
NewWindowProc = CallWindowProc(OldWindowProc, hwnd, Msg, wParam, lParam)
End If
End Function


form_Load:
hwndDataGrid = DataGrid1.hwnd
OldWindowProc = GetWindowLong(DataGrid1.hwnd, GWL_WNDPROC)
Call SetWindowLong(DataGrid1.hwnd, GWL_WNDPROC, AddressOf NewWindowProc)

[此贴子已经被作者于2007-10-11 11:52:27编辑过]


全国最大的 Java专业电子书免费分享[url]http:///in.asp?id=xrmao[/url]
2007-10-11 11:44
chaos_xia
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-4-22
得分:0 
很好,回去试试看。
2011-04-22 20:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-48844-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.111613 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved