Lock mouse wheel into main form, regardless of sub form? Or set event to focus on main form when clicking in background somewhere?

J Blizzard

New Member
Joined
Dec 23, 2019
Messages
20
Office Version
  1. 365
Platform
  1. Windows
I'm trying to use the mouse wheel on a form. This only works until clicking into a sub form, which switches the mouse wheel to the sub form. Is there a way to keep or switch the mouse wheel back to the main form without clicking on a field in the main form? I read a forum post which suggested creating a textbox of height and width of 0, then in the form properties making the mouse down event to select this text box, but that is not working for me and I don't know if I typed that wrong, implemented it wrong, or if it was a faulty suggestion. In any case, is there a way to either lock the mouse wheel exclusively to the main form, or to have the form properties such that when a user clicks in the form background area, it brings the mouse wheel back to the main form?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I was just browsing and noticed this two plus week old question unanswered.
I've never attempted to solve this exact issue.

Without seeing the example you're citing about a textbox with a height and width of 0 - subforms natively maintain a reference to parent forms. My guess is, the mouse down event executes code that goes to the H/W=0 Textbox. The Textbox is just a convenient spot to hang VBA code that then executes when it goes into focus. That event pushes the focus up to the mainform at which point as you continue to spin the wheel, it moves that form.

Mostly I'm writing that just trying to guess what it is attempting to do which might suggest where it is failing. That's if my guess is correct.
 
Upvote 0
I've used MouseHook.dll a long time ago but can't recall why. Maybe it was for this same issue, or it may have been that back then, mouse wheel didn't work on subforms. When I had the problem, mouse wheels were a new thing (giving away clues about my age). After a quick search I see that this page says you can turn off mouse scrolling for subforms, which seems like what is being asked for. Pretty sure this is the same source for the dll that I used.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top