請問可以使VB6.0的DATAGRID支援滑鼠中間的滾軸嗎?
2007-02-10 17:40:01 · 1 個解答 · 發問者 SKY 7 in 電腦與網際網路 ➔ 程式設計
'以下在模組
'*************************
Const WM_MOUSEWHEEL = &H20A
Declare Sub SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal H&, ByVal N&, ByVal D&)
Declare Function CallWindowProc& Lib "user32" Alias "CallWindowProcA" (ByVal L&, ByVal H&, ByVal M&, ByVal W&, ByVal L&)
Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" (ByVal H&, ByVal N&)
Public A&, B As Boolean
Function Scr&(ByVal H&, ByVal M As Long, ByVal P As Long, ByVal L As Long)
If M = WM_MOUSEWHEEL And B Then
If P < 0 Then
Form1.DBGrid1.Scroll 0, 1
Else
Form1.DBGrid1.Scroll 0, -1
End If
End If
Scr = CallWindowProc(A, H, M, P, L)
End Function
'以下在表單
'*******************************
Private Sub DBGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
B = True
End Sub
Private Sub Form_Load()
A = GetWindowLong(hwnd, -4)
SetWindowLong hwnd, -4, AddressOf Scr
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
B = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong hwnd, -4, A
End Sub
2007-02-12 14:48:12 · answer #1 · answered by W.J.S. 7 · 1⤊ 0⤋