Results 1 to 7 of 7

Thread: Kill the mouse wheel

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    88

    Kill the mouse wheel

    I have a form with Autoscroll = true

    When I scroll the mouse wheel and the focus is on a button or textbox, it is OK
    But when the focus is on a control like combobox or a listview (any control having its own scrollbar) no scrolling at the form level occur

    I want to kill the mouse wheel message sent to the combobox and send it back to the form.

    In VB6 I ve done it using subclassing. Should I do the same (I think using System.Windows.Forms.Form.WndProc) or is there a better way.

    and if this is the case, is there something like an Enum listing messages?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Kill the mouse wheel

    Sure you can cancel out the message WM_MOUSEWHEEL when the combo box is focused.

    Yes, you do use the WndProc overrides
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    88

    Re: Kill the mouse wheel

    OK, where can I find the values for such messages?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Kill the mouse wheel

    In the WndProc overrides procedure like in post #2.

    Just define your constant and place the code behind the form in question


    Code:
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    	Select Case m.Msg
    		Case WM_MOUSEWHEEL 
    			'Do your stuff here or cancel it by exiting the sub
    		Case Else
    			'
    	End Select
    	MyBase.WndProc(m)
    End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Kill the mouse wheel

    Rub I don't think it will work. I think the message is already in the message queue when WndProc gets the message. I guess it should be handled low-level.

    Another option would be using mouse hook. Check Global Hooks in my signature. Use it to hook the mouse and use this code below.
    vb Code:
    1. Private Sub gmh_MouseWheel(ByVal sender As System.IntPtr, ByVal e As WindowsHookLib.LLMouseEventArgs) Handles gmh.MouseWheel
    2.     If Me.ComboBox1.Focused Then
    3.         e.Handled = True
    4.     End If
    5. End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    88

    Re: Kill the mouse wheel

    In post #3 I asked about the value of the WM_MOUSEWHEEL constant, where can I find these values e.g.
    Code:
    Public Const WM_MOUSEWHEEL As Integer = ??
    Is there a place of such values?
    Last edited by Amr Al-Amir; Jul 29th, 2007 at 06:07 PM.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Kill the mouse wheel

    You can get API utilities like the API Viewer utility (link in my signature) or also at pinvoke.net for another.

    Code:
    Private Const WM_MOUSEWHEEL As Int32 = &H20A
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width