BUG: No WM_MOUSEWHEEL Message is Received after Adding a UserControl to a FormID: Q231465
|
After adding a User control to a Form, the Visual Basic design environment (IDE) ignores the WM_MOUSEWHEEL message when you roll the wheel of the mouse. This problem does not occur on Windows NT.
The Visual Basic Design Environment (IDE) is not compatible with early versions of the Microsoft Intellimouse driver.
Download the latest driver update for the Microsoft Intellimouse from:
http://www.microsoft.com/products/hardware/mouse/driver/default.htm
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Option Explicit
Private Sub Form_Load()
Me.Show
Call SubClassHookForm
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call SubClassUnHookForm
End Sub
Option Explicit
Private MSWHEEL_ROLLMSG As Long
Private m_PrevWndProc As Long
Private Const GWL_WNDPROC = (-4)
Private 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
Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function RegisterWindowMessage Lib "user32" _
Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Public Sub SubClassHookForm()
MSWHEEL_ROLLMSG = RegisterWindowMessage("MSWHEEL_ROLLMSG")
' On Windows NT 4.0 and Windows 98, change the above line to
' MSWHEEL_ROLLMSG = &H20A
m_PrevWndProc = SetWindowLong(Form1.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
End Sub
Public Sub SubClassUnHookForm()
Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, m_PrevWndProc)
End Sub
Public Function WindowProc(ByVal hwnd As Long, ByVal msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
If msg = MSWHEEL_ROLLMSG Then
Debug.Print "Receive MSWHEEL_ROLLMSG"
End If
WindowProc = CallWindowProc(m_PrevWndProc, hwnd, msg, wParam, lParam)
End Function
For additional information, please click the article number below to view the article in the Microsoft Knowledge Base:
Q168795 HOWTO: Hook Into a Window's Messages using AddressOf
Additional query words: wm_mousewheel user control hook
Keywords : kbMouse kbVBp kbVBp500bug kbVBp600bug kbWndwMsg kbGrpVB kbDSupport
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: August 12, 1999