如何在Access2000窗体中检测并禁止通过鼠标滚轮滚动到其他记录
http://www.faq-it.org/apache/">faq-it.org/apache/ 大家都知道,在Access的默认情况下,你可以通过使用鼠标滚轮从一条记录滚动到另一条记录,但是Access本身似乎并没有提供对鼠标滚轮的完全控制和检测的方法(关于这点,你可以参考本站文章《如何禁用鼠标滚轮?》)。
这里,你可以通过两种方法来检测并控制鼠标滚轮:
一、用 VB VC 编写 ActiveX DLL,通过在Access中引用该DLL来解决;(MS 推荐)
二、你可以在 Access 本身的 VBA 代码中引用 API 函数建立子类来解决问题。
以下就是方法一的操作过程:
1、打开 Microsoft Visual Basic 6.0.
2、建立一个新的 ActiveX DLL 项目并打开
3、将以下代码加入一个类模块中:
Option Compare Text
Option Explicit
Private frm As Object
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
Public Property Set Form(frmIn As Object)
Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
MouseWheelCancel = intCancel
End Property
Public Sub SubClassHookForm()
lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
Set Cmouse = Me
End Sub
Public Sub SubClassUnHookForm()
Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Sub FireMouseWheel()
RaiseEvent MouseWheel(intCancel)
End Sub
4、命名为: CMouseWheel
5、修改以下属性:
Name: CMouseWheel
Instancing: 5 - MultiUse
6、新建一个标准模块,然后加入以下代码:
Option Compare Text
Option Explicit
Public Cmouse As CMouseWheel
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_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Select Case uMsg
Case WM_MouseWheel
Cmouse.FireMouseWheel
If Cmouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
7、更改项目名称为:MouseWheel
8、保存该项目、类模块、标准模块
basSubClassWindow.bas
CMouseWheel.cls
MouseWheel.vbp respectively.
9、用“文件”菜单上的 建立 MouseWheel.dll 生成一个dll文件。
10、退出 VB 并打开 Access,打开示例数据库 Northwind.mdb
11、转到 VBE 界面,打开 form_Customers 类模块
12、工具菜单 -> 引用 ,然后找到你刚才生成的 MouseWheel.DLL 并选勾。
13、加入以下代码到该模块:
Option Compare Database
Option Explicit
Private WithEvents clsMouseWheel As MouseWheel.CMouseWheel
Private Sub Form_Load()
Set clsMouseWheel = New MouseWheel.CMouseWheel
Set clsMouseWheel.Form = Me
clsMouseWheel.SubClassHookForm
End Sub
Private Sub Form_Close()
clsMouseWheel.SubClassUnHookForm
Set clsMouseWheel.Form = Nothing
Set clsMouseWheel = Nothing
End Sub
Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
MsgBox "You cannot use the mouse wheel to scroll records."
Cancel = True
End Sub
14、关闭,保存,打开窗体 Customers,然后滚动鼠标滚轮,你就会得到以下提示:
You cannot use the mouse wheel to scroll records.
并且在提示的同时,当前记录并没有改动。
注意,如果你的 Access 程序的使用者已经加载了 VBE ,使用上述方法可能导致 Access 长时间停顿,你将不得不强行终止 Access 程序。所以,在进行上述操作时请注意备份数据库。
-----------------------------------------------------
方法二的操作过程:
下面示例如何在 Access 中直接写类模块来检测并禁止鼠标滚轮。(再说一遍:请先备份)
1、打开 Access ,并打开示例数据库 Northwind.mdb.
2、在 VBE 界面建立一个新的模块,并加入以下代码:
Option Compare Database
Option Explicit
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_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public Cmouse As CMouseWheel
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
'Look at the message passed to the window. If it is
'a mouse wheel message, call the FireMouseWheel procedure
'in the CMouseWheel class, which in turn raises the MouseWheel
'event. If the Cancel argument in the form event procedure is
'set to False, then we process the message normally, otherwise
'we ignore it. If the message is something other than the mouse
'wheel, then process it normally
Select Case uMsg
Case WM_MouseWheel
Cmouse.FireMouseWheel
If Cmouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
3、保存类,名为:basSubClassWindow
4、建立一个类模块,并且加入以下代码:
Option Compare Database
Option Explicit
Private frm As Access.Form
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
Public Property Set Form(frmIn As Access.Form)
'Define Property procedure for the class which
'allows us to set the Form object we are
'using with it. This property is set from the
'form class module.
Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
'Define Property procedure for the class which
'allows us to retrieve whether or not the Form
'event procedure canceled the MouseWheel event.
'This property is retrieved by the WindowProc
'function in the standard basSubClassWindow
'module.
MouseWheelCancel = intCancel
End Property
Public Sub SubClassHookForm()
'Called from the form's OnOpen or OnLoad
'event. This procedure is what "hooks" or
'subclasses the form window. If you hook the
'the form window, you must unhook it when completed
'or Access will crash.
lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
Set Cmouse = Me
End Sub
Public Sub SubClassUnHookForm()
'Called from the form's OnClose event.
'This procedure must be called to unhook the
'form window if the SubClassHookForm procedure
'has previously been called. Otherwise, Access will
'crash.
Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Sub FireMouseWheel()
'Called from the WindowProc function in the
'basSubClassWindow module. Used to raise the
'MouseWheel event when the WindowProc function
'intercepts a mouse wheel message.
RaiseEvent MouseWheel(intCancel)
End Sub
5、保存类模块,名字为:CMouseWheel
6、打开 form_Customers 类,加入以下代码:
Option Compare Database
Option Explicit
'Declare a module level variable as the custom class
'and give us access to the class's events
Private WithEvents clsMouseWheel As CMouseWheel
Private Sub Form_Load()
'Create a new instance of the class,
'and set the class's Form property to
'the current form
Set
# Name (required)
# Mail (will not be published)
# Website
如何在Access2000窗体中检测并禁止通过鼠标滚轮滚动到其他记录
http://www.faq-it.org/apache/">faq-it.org/apache/ 大家都知道,在Access的默认情况下,你可以通过使用鼠标滚轮从一条记录滚动到另一条记录,但是Access本身似乎并没有提供对鼠标滚轮的完全控制和检测的方法(关于这点,你可以参考本站文章《如何禁用鼠标滚轮?》)。
这里,你可以通过两种方法来检测并控制鼠标滚轮:
一、用 VB VC 编写 ActiveX DLL,通过在Access中引用该DLL来解决;(MS 推荐)
二、你可以在 Access 本身的 VBA 代码中引用 API 函数建立子类来解决问题。
以下就是方法一的操作过程:
1、打开 Microsoft Visual Basic 6.0.
2、建立一个新的 ActiveX DLL 项目并打开
3、将以下代码加入一个类模块中:
Option Compare Text
Option Explicit
Private frm As Object
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
Public Property Set Form(frmIn As Object)
Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
MouseWheelCancel = intCancel
End Property
Public Sub SubClassHookForm()
lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
Set Cmouse = Me
End Sub
Public Sub SubClassUnHookForm()
Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Sub FireMouseWheel()
RaiseEvent MouseWheel(intCancel)
End Sub
4、命名为: CMouseWheel
5、修改以下属性:
Name: CMouseWheel
Instancing: 5 - MultiUse
6、新建一个标准模块,然后加入以下代码:
Option Compare Text
Option Explicit
Public Cmouse As CMouseWheel
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_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Select Case uMsg
Case WM_MouseWheel
Cmouse.FireMouseWheel
If Cmouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
7、更改项目名称为:MouseWheel
8、保存该项目、类模块、标准模块
basSubClassWindow.bas
CMouseWheel.cls
MouseWheel.vbp respectively.
9、用“文件”菜单上的 建立 MouseWheel.dll 生成一个dll文件。
10、退出 VB 并打开 Access,打开示例数据库 Northwind.mdb
11、转到 VBE 界面,打开 form_Customers 类模块
12、工具菜单 -> 引用 ,然后找到你刚才生成的 MouseWheel.DLL 并选勾。
13、加入以下代码到该模块:
Option Compare Database
Option Explicit
Private WithEvents clsMouseWheel As MouseWheel.CMouseWheel
Private Sub Form_Load()
Set clsMouseWheel = New MouseWheel.CMouseWheel
Set clsMouseWheel.Form = Me
clsMouseWheel.SubClassHookForm
End Sub
Private Sub Form_Close()
clsMouseWheel.SubClassUnHookForm
Set clsMouseWheel.Form = Nothing
Set clsMouseWheel = Nothing
End Sub
Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
MsgBox "You cannot use the mouse wheel to scroll records."
Cancel = True
End Sub
14、关闭,保存,打开窗体 Customers,然后滚动鼠标滚轮,你就会得到以下提示:
You cannot use the mouse wheel to scroll records.
并且在提示的同时,当前记录并没有改动。
注意,如果你的 Access 程序的使用者已经加载了 VBE ,使用上述方法可能导致 Access 长时间停顿,你将不得不强行终止 Access 程序。所以,在进行上述操作时请注意备份数据库。
-----------------------------------------------------
方法二的操作过程:
下面示例如何在 Access 中直接写类模块来检测并禁止鼠标滚轮。(再说一遍:请先备份)
1、打开 Access ,并打开示例数据库 Northwind.mdb.
2、在 VBE 界面建立一个新的模块,并加入以下代码:
Option Compare Database
Option Explicit
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_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public Cmouse As CMouseWheel
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
'Look at the message passed to the window. If it is
'a mouse wheel message, call the FireMouseWheel procedure
'in the CMouseWheel class, which in turn raises the MouseWheel
'event. If the Cancel argument in the form event procedure is
'set to False, then we process the message normally, otherwise
'we ignore it. If the message is something other than the mouse
'wheel, then process it normally
Select Case uMsg
Case WM_MouseWheel
Cmouse.FireMouseWheel
If Cmouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
3、保存类,名为:basSubClassWindow
4、建立一个类模块,并且加入以下代码:
Option Compare Database
Option Explicit
Private frm As Access.Form
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
Public Property Set Form(frmIn As Access.Form)
'Define Property procedure for the class which
'allows us to set the Form object we are
'using with it. This property is set from the
'form class module.
Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
'Define Property procedure for the class which
'allows us to retrieve whether or not the Form
'event procedure canceled the MouseWheel event.
'This property is retrieved by the WindowProc
'function in the standard basSubClassWindow
'module.
MouseWheelCancel = intCancel
End Property
Public Sub SubClassHookForm()
'Called from the form's OnOpen or OnLoad
'event. This procedure is what "hooks" or
'subclasses the form window. If you hook the
'the form window, you must unhook it when completed
'or Access will crash.
lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
Set Cmouse = Me
End Sub
Public Sub SubClassUnHookForm()
'Called from the form's OnClose event.
'This procedure must be called to unhook the
'form window if the SubClassHookForm procedure
'has previously been called. Otherwise, Access will
'crash.
Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Sub FireMouseWheel()
'Called from the WindowProc function in the
'basSubClassWindow module. Used to raise the
'MouseWheel event when the WindowProc function
'intercepts a mouse wheel message.
RaiseEvent MouseWheel(intCancel)
End Sub
5、保存类模块,名字为:CMouseWheel
6、打开 form_Customers 类,加入以下代码:
Option Compare Database
Option Explicit
'Declare a module level variable as the custom class
'and give us access to the class's events
Private WithEvents clsMouseWheel As CMouseWheel
Private Sub Form_Load()
'Create a new instance of the class,
'and set the class's Form property to
'the current form
Set
# Name (required)
# Mail (will not be published)
# Website
如何在Access2000窗体中检测并禁止通过鼠标滚轮滚动到其他记录 大家都知道,在Access的默认情况下,你可以通过使用鼠标滚轮从一条记录滚动到另一条记录,但是Access本身似乎并没有提供对鼠标滚轮的完全控制和检测的方法(关于这点,你可以参考本站文章《如何禁用鼠标滚轮?》)。
这里,你可以通过两种方法来检测并控制鼠标滚轮:
一、用 VB VC 编写 ActiveX DLL,通过在Access中引用该DLL来解决;(MS 推荐)
二、你可以在 Access 本身的 VBA 代码中引用 API 函数建立子类来解决问题。
以下就是方法一的操作过程:
1、打开 Microsoft Visual Basic 6.0.
2、建立一个新的 ActiveX DLL 项目并打开
3、将以下代码加入一个类模块中:
Option Compare Text
Option Explicit
Private frm As Object
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
Public Property Set Form(frmIn As Object)
Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
MouseWheelCancel = intCancel
End Property
Public Sub SubClassHookForm()
lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
Set Cmouse = Me
End Sub
Public Sub SubClassUnHookForm()
Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Sub FireMouseWheel()
RaiseEvent MouseWheel(intCancel)
End Sub
4、命名为: CMouseWheel
5、修改以下属性:
Name: CMouseWheel
Instancing: 5 - MultiUse
6、新建一个标准模块,然后加入以下代码:
Option Compare Text
Option Explicit
Public Cmouse As CMouseWheel
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_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Select Case uMsg
Case WM_MouseWheel
Cmouse.FireMouseWheel
If Cmouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
7、更改项目名称为:MouseWheel
8、保存该项目、类模块、标准模块
basSubClassWindow.bas
CMouseWheel.cls
MouseWheel.vbp respectively.
9、用“文件”菜单上的 建立 MouseWheel.dll 生成一个dll文件。
10、退出 VB 并打开 Access,打开示例数据库 Northwind.mdb
11、转到 VBE 界面,打开 form_Customers 类模块
12、工具菜单 -> 引用 ,然后找到你刚才生成的 MouseWheel.DLL 并选勾。
13、加入以下代码到该模块:
Option Compare Database
Option Explicit
Private WithEvents clsMouseWheel As MouseWheel.CMouseWheel
Private Sub Form_Load()
Set clsMouseWheel = New MouseWheel.CMouseWheel
Set clsMouseWheel.Form = Me
clsMouseWheel.SubClassHookForm
End Sub
Private Sub Form_Close()
clsMouseWheel.SubClassUnHookForm
Set clsMouseWheel.Form = Nothing
Set clsMouseWheel = Nothing
End Sub
Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
MsgBox "You cannot use the mouse wheel to scroll records."
Cancel = True
End Sub
14、关闭,保存,打开窗体 Customers,然后滚动鼠标滚轮,你就会得到以下提示:
You cannot use the mouse wheel to scroll records.
并且在提示的同时,当前记录并没有改动。
注意,如果你的 Access 程序的使用者已经加载了 VBE ,使用上述方法可能导致 Access 长时间停顿,你将不得不强行终止 Access 程序。所以,在进行上述操作时请注意备份数据库。
-----------------------------------------------------
方法二的操作过程:
下面示例如何在 Access 中直接写类模块来检测并禁止鼠标滚轮。(再说一遍:请先备份)
1、打开 Access ,并打开示例数据库 Northwind.mdb.
2、在 VBE 界面建立一个新的模块,并加入以下代码:
Option Compare Database
Option Explicit
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_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public Cmouse As CMouseWheel
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
'Look at the message passed to the window. If it is
'a mouse wheel message, call the FireMouseWheel procedure
'in the CMouseWheel class, which in turn raises the MouseWheel
'event. If the Cancel argument in the form event procedure is
'set to False, then we process the message normally, otherwise
'we ignore it. If the message is something other than the mouse
'wheel, then process it normally
Select Case uMsg
Case WM_MouseWheel
Cmouse.FireMouseWheel
If Cmouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
3、保存类,名为:basSubClassWindow
4、建立一个类模块,并且加入以下代码:
Option Compare Database
Option Explicit
Private frm As Access.Form
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
Public Property Set Form(frmIn As Access.Form)
'Define Property procedure for the class which
'allows us to set the Form object we are
'using with it. This property is set from the
'form class module.
Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
'Define Property procedure for the class which
'allows us to retrieve whether or not the Form
'event procedure canceled the MouseWheel event.
'This property is retrieved by the WindowProc
'function in the standard basSubClassWindow
'module.
MouseWheelCancel = intCancel
End Property
Public Sub SubClassHookForm()
'Called from the form's OnOpen or OnLoad
'event. This procedure is what "hooks" or
'subclasses the form window. If you hook the
'the form window, you must unhook it when completed
'or Access will crash.
lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
Set Cmouse = Me
End Sub
Public Sub SubClassUnHookForm()
'Called from the form's OnClose event.
'This procedure must be called to unhook the
'form window if the SubClassHookForm procedure
'has previously been called. Otherwise, Access will
'crash.
Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Sub FireMouseWheel()
'Called from the WindowProc function in the
'basSubClassWindow module. Used to raise the
'MouseWheel event when the WindowProc function
'intercepts a mouse wheel message.
RaiseEvent MouseWheel(intCancel)
End Sub
5、保存类模块,名字为:CMouseWheel
6、打开 form_Customers 类,加入以下代码:
Option Compare Database
Option Explicit
'Declare a module level variable as the custom class
'and give us access to the class's events
Private WithEvents clsMouseWheel As CMouseWheel
Private Sub Form_Load()
'Create a new instance of the class,
'and set the class's Form property to
'the current form
Set
# Name (required)
# Mail (will not be published)
# Website
你有病啊!这么麻烦。拿个胶布把鼠标滚轮粘上不就可以了?要这么麻烦吗?