问题描述
Activewindow.UsableWidth给我屏幕的宽度,其中包括垂直滚动条的宽度.有什么方法可以计算滚动条的宽度吗?我通过将一个形状设置为UsableWidth,将另一个形状设置为实际可以看到的形状来进行测量,所不同的是滚动条的宽度.我想知道是否有一种方法可以使其自动化,以便可以由分辨率更高或更低,因此滚动条更小或更大的用户使用.
Activewindow.UsableWidth gives me the width of the screen with the Vertical Scroll Bar's width included. Is there a way I can calculate the width of the Scroll Bar? I measured it by having one shape be UsableWidth and the other shape be what I actually can see, and the difference is the width of the Scroll Bar. I'm wondering if there's a way to automate it so it can be used by a user with a higher or lower resolution, and therefore smaller or larger Scroll Bar.
谢谢!
推荐答案
如果要查找垂直滚动条宽度的值,则可以使用Windows API调用:
If you are looking to find the value for the vertical scrollbar width, you can use a Windows API call:
Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Public Const SM_CXVSCROLL = 2
______________________________________
Sub ShowVScrollWidth()
Dim lVScrollWidth As Long
lVScrollWidth = GetSystemMetrics32(SM_CXVSCROLL)
Debug.Print lVScrollWidth
End Sub
(改编自此页面上的信息.有关可用GetSystemMetrics的更多信息可以在此MSDN页面上找到参数.)
(Adapted from the info on this page. More info on the available GetSystemMetrics parameters can be found at this MSDN page.)
这篇关于查找Excel滚动条的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!