cristianbuse / VBA-UserForm-MouseScroll

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

crash after using mouse scroll for a while #31

Closed joeyda closed 11 months ago

joeyda commented 11 months ago

The most recent version of this library with modeless form support is working perfectly for us with Autodesk Inventor but we are running into an issue where over time, our program will crash without warning.

Previously we were running into unexpected error 35010? Which seemed to come from VBA's compile on demand. Now on the new version it will crash without any error, do you think this is also due to compile on demand or due to some other change?

cristianbuse commented 11 months ago

Hi @joeyda ,

Unfortunately, I cannot replicate the issue. I even tried turning on the compile on demand. However, I have only tested on Microsoft Office Applications.

Are you able to turn compile on demand off and see if that helps? Out of curiosity, is there any reason why you use that feature? I ask because it has only caused me issues over the years and I simply stopped using it.

Thanks!

joeyda commented 11 months ago

I believe it was just on by default and I have never turned it off. It was covering up some flaws in our code. I cleaned that up and turned off compile on demand and I didn't have a crash last friday. I'll keep testing

joeyda commented 11 months ago

Turning off compile on demand has fixed my issues

cristianbuse commented 11 months ago

Hi @joeyda ,

Many thanks for confirming!

For me it does make sense. I am even willing to bet you are using Inventor on 64-bit architecture.

When I added support for Modeless forms I had to figure out a way to workaround a bug with hooks that was causing crashing. The same bug affects Timers callbacks in VB*.

The way I solved it was to redirect the call via a fake callback which ensures the correct memory alignment for the arguments on the stack. That is a x64 fix hence my suspicion you are on x64. Having compile on demand on was basically erasing the fix in between hooking different forms.