VB: How to prevent MouseWheel msgs from auto-generating scrollbar msgs?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mike1reynolds
    New Member
    • Apr 2008
    • 8

    #1

    VB: How to prevent MouseWheel msgs from auto-generating scrollbar msgs?

    I have a VirtualMode DataGridView that bogs down on using the mouse wheel to scroll and gets a backlog of messages such that it continues to scroll long after ceasing to turn the mouse wheel. This is because instead of generating one scrollbar message for each mouse wheel message it generates a separate scrollbar message for each line move, forcing the entire screen to refresh with each line added.

    I've put in code to scroll multiple lines only once for each mouse wheel click, but I'm still having to shunt out all of the extra scrollbar messages and it is not easy. If I get out of sync as to how many scrollbar messages to shunt the scrolling goes out of whack. It would be far easier if I just didn't have to worry about shunting these useless messages.

    So how do you prevent mouse wheel messages from creating scrollbar messages?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You can try overrideing the WndProc function on your form. And parse out the mouse wheel messages?

    Comment

    • mike1reynolds
      New Member
      • Apr 2008
      • 8

      #3
      I'm not getting any scrollbar messages in the form's WndProc function (nor any mouse wheel messages) so as I turn the mouse wheel I get no output in the immediate window from the following code:

      Protected Overrides Sub WndProc(ByRef m As Message)
      Debug.WriteLine (m.Msg)
      MyBase.WndProc( m)
      End Sub

      Moving the mouse around does give me messages.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Well I don't know what that Debug call does, nothing ever showed up in my window.

        I used Console.Writeli ne and saw them all.

        MouseWheel is when m.Msg is 0x20a if that helps.

        Comment

        • mike1reynolds
          New Member
          • Apr 2008
          • 8

          #5
          I was able to get them by deriving a class from DataGridView and overriding it's WndProc.

          Comment

          Working...