Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 459
  • Last Modified:

Disable Mouse wheel without using API?

Is it possible to disable the mouse scroll wheel without any API?
  • 3
  • 2
1 Solution
To the best of my knowledge, you can't.

However, I had the same problem in VB6.
I found a great web page to deal with the subclassing at


This allows subclassing multiple objects on a single form.
Other search results found a method that would only handle one object on a form.

Warning: Requires API declares.
adamkushnerAuthor Commented:

Thanks for your input.

Basically I'm avoiding API's cause it's way over my head.  I'd love to learn, but don't have the time right now.  I'm working on a project that requires me to disable the scroll wheel, and don't want to spend too much time on it.  But it looks like that is unavoidable at this point.

Anyway, maybe you can help me around it...

I have a combobox, when an item in the combo box is clicked data is pulled from my database an inserted into a text box.  

I guess a the mouse wheel evaluates to a click so when the combo box gains focus and the mouse wheel is scrolled, all values are cliked and the text box is filled with almost all possible values.

Any way around this?

adamkushnerAuthor Commented:
By the way I am coding in VB6,
don't know if this changes anything
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

adamkushnerAuthor Commented:
How about using API?
Anyone have code required to do this?
 here is the code I used to supress mousewheel use within a combo box.

'Form Declares (at top of form under Option Explicit)
Dim WithEvents clsMWcboSelectBy     As CMouseWheel 'scroll wheel control

    Set clsMWcboSelectBy = New CMouseWheel
    Set clsMWcboSelectBy.Form = cboSelectBy    'cboSelectBy is a control on the form
    clsMWcboSelectBy.SubClassHookForm          ' turn on supress mouseweheel

    clsMWcboSelection.SubClassUnHookForm  '' turn off supress mouseweheel
    Set clsMWcboSelection = Nothing

'Class Module named CMouseWheel

Option Compare Text
Option Explicit

'it is a good idea to compile a program that uses sub-classing with the 'native code' option.

Dim m_MyInstance As Integer ' locally kept instance identifier

Private frm As Object
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer, MsgNum As Long, wParam As Long)

Public Property Set Form(frmIn As Object)
    Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
    MouseWheelCancel = intCancel
End Property

Private Sub Class_Initialize()
' Place this block of code in the
' INITIALIZE event to 'register' the instance with the array of instances.
Dim Instance_Scan As Integer
    If Instances(Instance_Scan).in_use = False Then     ' this item is empty
        m_MyInstance = Instance_Scan                    ' save this instance index in me
        Instances(Instance_Scan).in_use = True          ' turn on in-use flag
        Instances(Instance_Scan).ClassAddr = ObjPtr(Me) ' save the me object identifier
        Exit For
    End If
Next Instance_Scan

End Sub

Public Sub SubClassHookForm()
    Call Hook_Window(frm.hwnd, m_MyInstance)
    'lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, AddressOf WindowProc)
   End Sub

Public Sub SubClassUnHookForm()
    Call UnHookWindow(m_MyInstance)
    'Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub

Friend Function FireEvent(MsgNum As Long, wParam As Long) As Integer
' Note the Friend keyword.
' If you plan on modifying wMsg, pass it ByRef...
        'Debug.Print "FireEvent for " & MsgNum & " instnum " & m_MyInstance & ", wparam=" & wParam
    FireEvent = -1 ' continue message unless stopped
    RaiseEvent MouseWheel(intCancel, MsgNum, wParam)
        'Debug.Print "Raise returns " & intCancel
    FireEvent = intCancel
End Function

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now