?
Solved

Disable Mouse wheel without using API?

Posted on 2003-03-11
6
Medium Priority
?
434 Views
Last Modified: 2010-02-22
Is it possible to disable the mouse scroll wheel without any API?
0
Comment
Question by:adamkushner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:JohnChapin
ID: 8113836
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

www.missouri.edu/~finaidtk/sboard.htm

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.
0
 

Author Comment

by:adamkushner
ID: 8131820
JohnChapin,

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?


0
 

Author Comment

by:adamkushner
ID: 8131847
By the way I am coding in VB6,
don't know if this changes anything
0
Independent Software Vendors: 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!

 

Author Comment

by:adamkushner
ID: 8301110
How about using API?
Anyone have code required to do this?
0
 
LVL 4

Accepted Solution

by:
JohnChapin earned 400 total points
ID: 8302589
Adam,
 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

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


'Form_Unload
    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
   
For Instance_Scan = MIN_INSTANCES To MAX_INSTANCES
    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
0
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 26826255
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question