如何在 MS Access VBA 中检索屏幕大小/分辨率以重新调整表单大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11843310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to retrieve screen size/resolution in MS Access VBA to re-size a form
提问by aSystemOverload
I have two popup forms (parent/child) that I want to be able to automatically re-size depending on the size of the screen.
我有两个弹出窗体(父/子),我希望能够根据屏幕的大小自动调整大小。
How can I retrieve the size of the screen in order to achieve this.
如何检索屏幕的大小以实现此目的。
回答by Fionnuala
For Access 2010 64 bit, you will need to add PtrSafe
before Function
.
对于 Access 2010 64 位,您需要PtrSafe
在Function
.
Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub ScreenRes()
Dim w As Long, h As Long
w = GetSystemMetrics32(0) ' width in points
h = GetSystemMetrics32(1) ' height in points
End Sub
More info: http://support.microsoft.com/kb/210603
回答by CODE-REaD
For VBA, a simpler (and therefore possibly more portable) solution might be:
对于 VBA,一个更简单(因此可能更便携)的解决方案可能是:
Application.UsableHeight
Application.UsableWidth
As found at Adjust userforms to fit in screen. I am using this successfully with Word 2007 VBA. In my case, Application.UsableWidth
gives the actual screen width, Application.UsableHeight
gives the actual screen height, minus the height of Windows' taskbar.
正如在Adjust userforms to fit in screen 中找到的那样。我在 Word 2007 VBA 中成功使用了它。在我的情况下,Application.UsableWidth
给出实际屏幕宽度,Application.UsableHeight
给出实际屏幕高度,减去 Windows 任务栏的高度。