Results 1 to 40 of 47

Thread: VB6-MouseWheel With Any Control

Threaded View

  1. #1

    Thread Starter
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    VB6-MouseWheel With Any Control

    Note: The most up-to-date version of the code is in post #1. WheelHookAllControls.zip includes MSFlexGrid example


    It was brought to my attention that controls that already responded to the MouseWheel (combobox, textbox, etc.), would prevent MouseWheel events passing to form, so even if you were over a grid, it would be the combobox that scrolled, and you would have to remove focus from the control before it would work

    I have fixed this so that you can Hook the controls, and if a WM_MOUSEWHEEL event occurs and the mouse is not over the control, it triggers the MouseWheel sub on the form.

    The code for scrolling the grid if it's the activecontrol will work fine regardless of other controls responding to scroll events.



    EDIT: This was recovered from the original post. The original two attachments are the links WheelHook-NestedControls and WheelHook-AllControls:

    These example projects demonstrate enabling the MouseWheel for any control (multiple controls / multiple forms).

    Examples

    Enabling MouseWheel Support with any control - attached to post #1
    14/03/06: Slight correction to code
    20/04/06: Minor modification to code (more info: post #9)
    12/01/07: Nested Controls example created allowing the mousewheel to work with controls nested to any depth - incorporates fixes from other posts (1, 2) - attached to post #1

    Scrolling the MSFlexGrid that the mouse is over - attached to post #2
    21/02/06: Small bug fix

    Scrolling if the MSFlexGrid is the active control - attached in post #13 of original thread


    The hooking code was modified from here.
    Original thread, with suggestions from other members.

    Note:
    These codes use subclassing which can cause your IDE to crash if your code is incorrectly ended (e.g. via the stop button).
    See here for adding in code to detect if your program is running in the IDEWheelHook-NestedControls.zipWheelHook-AllControls.zip
    Attached Files Attached Files

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