|
1. 直接使用Access自身的方法
DoCmd.Echo False
Dim X, Y As Integer
DoCmd.Maximize
X = Me.InsideWidth
Y = Me.InsideHeight
DoCmd.Restore
DoCmd.Echo True
DoCmd.MoveSize (X - Me.InsideWidth) / 2, 0 '(y - Me.WindowHeight) / 2
缺点: 取得屏幕的宽度和高度 , 有点闪烁
2.使用API的方法
Declare Function GetSystemMetrics32 Lib "user32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub DisplayMonitorInfo()
Dim X As Long, Y As Long
X = GetSystemMetrics32(0) ' 宽度(像素)
Y = GetSystemMetrics32(1) ' 高度(像素)
MsgBox "屏幕分辨率为:" & X & " × " & Y & " 像素"
End Sub
推荐: 更好, 更准确,不闪烁
3.只适用VB的方法
Private Sub Form_Load()
MsgBox ("桌面宽度为:" & Screen.Width / Screen.TwipsPerPixelX & "像素,高度为:" & Screen.Height / Screen.TwipsPerPixelY & "像素")
End Sub
|
|