通过ActiveWindow缩放事件触发事件(按住CTRL +鼠标滚轮) [英] Event triggered with ActiveWindow zoom event (holding CTRL+Mouse wheel)
问题描述
我正在构建仪表板,需要将缩放级别设置为100%
.因此,每当用户尝试使用鼠标滚轮按钮或缩放级别"选项进行缩放时,我都需要捕获该事件并将缩放"返回到100%
.我在互联网上搜索了答案,发现没有OnZoom事件.
I am building a dashboard and need to have zoom level set to 100%
. So whenever User tries to Zoom using mouse wheel button or Zoom level option, I need to catch that event and return Zoom to 100%
. I have searched all over internet for answer and found that there is no such thing as OnZoom event.
- 有一个选项可以每隔几毫秒检查一次缩放级别,然后 将其恢复到100%,但我无法接受导致圆整的原因 不断出现在鼠标箭头上,这很分散注意力.
- 也不能选择隐藏缩放控件,因为用户仍然可以缩放 使用CTRL + MouseWheel.
- 使用Class模块也仅在手动选择缩放级别时起作用
从菜单
View > Zoom
解决方案
- There is an option to check zoom level every few milliseconds and restore it to 100%, but i can't accept this cause of rounding circle appearing on mouse arrow constantly, which is distracting.
- Hiding Zoom control is also not an option since user can still zoom with CTRL+MouseWheel.
- Using Class modules also work only on manual selecting zoom level
from menu
View > Zoom
solution
我找到的所有答案都是在5年前发布的,所以也许与此同时有人找到了解决方案,或者在较新版本的Excel中添加了此功能?
All answers I found were dated more than 5 years ago, so maybe in the meantime someone found a solution or this feature is added in newer versions of Excel?
任何线索都将不胜感激!
Any lead will be much appreciated!
推荐答案
在使用ActiveX控件时找到了解决方案,因此对于偶然发现此问题的每个人,请在下面找到答案.
Found a solution while playing with ActiveX controls, so for everyone who stumbled on this please find answer below.
首先,插入名为InkPicture control
的ActiveX控件.
First, insert ActiveX control named InkPicture control
.
在整个工作表可见区域调整控件的大小.
Resize control across whole Worksheet visible area.
在工作表模块中,粘贴此代码.
In worksheet module, paste this code.
Private Sub InkPicture1_Resize(Left As Long, Top As Long, Right As Long, Bottom As Long)
ActiveWindow.Zoom = 100
End Sub
由于某种原因(希望有人可以解释原因?),发生缩放时,它将触发InkPicture_resize事件!
您还可以将InkPicture visible property
设置为false
,它仍然可以使用.
For some reason (hope someone can explain why?), when zooming occures, it triggers InkPicture_resize event!
You can also set InkPicture visible property
to false
, and it will still works.
这篇关于通过ActiveWindow缩放事件触发事件(按住CTRL +鼠标滚轮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!