cristianbuse / VBA-UserForm-MouseScroll

Use the Mouse Scroll Wheel to scroll VBA UserForms and Controls
MIT License
70 stars 12 forks source link

VBA UserForm MouseScroll settings #40

Closed vovanius closed 4 months ago

vovanius commented 4 months ago

Hi there! You did an excellent job! All works good so far, but I have a few questions: -first, how can I set the scroll speed (number of rows/columns scrolled per wheel tick)? -second, how can I disable certain functions, such as zoom or horizontal scrolling, leaving only vertical scrolling? -third, when vertically scrolling a text box, even in Your demo file, vertical slider moves a bit jerky. Not critical issue, rather cosmetic...

Thanks in advance, nice day!

cristianbuse commented 4 months ago

Hi @vovanius

Thank you for the kind words!

If you go to the Mouse Settings in Windows, you can edit the number of lines to scroll or you can even set to scroll one screen at a time. In my Windows 10 it looks like this: image

This repo will then detect the new settings and work accordingly.

However, if you don't want to change the system settings for the mouse, then you can just edit the code as you wish. For example, inside the GetScrollAmount function you can overwrite the return value as you wish.

As for the zoom and horizontal scroll, you can disable them by replacing this line of code. For example, replace:

scrollAction = GetScrollAction(yWheel:=(m_wParam = WM_MOUSEWHEEL))

with just:

scrollAction = saScrollY

Would it be useful to add an option for this? Like an extra parameter to EnableMouseScroll?

vovanius commented 4 months ago

Hello again)) Thank You for fast and informative reply! Yes, it would be very useful to add disable/enable options for every function, so user could switch them according to "here and now" needs. Kind regards))

cristianbuse commented 4 months ago

Hi @vovanius ,

I've added the options as extra parameters to the EnableMouseScroll method. They are True by default but can be changed to False for each individual form, as needed. Please let me know if this works for you. Thanks!

vovanius commented 4 months ago

Thank You again for fast response and code update. I tested new version, all works great. I will use my app with this updated modules for a while, and if anything goes wrong, I will let You know. Kind regards))