Private Type RECT
Left As Long 'X坐标,0
Top As Long 'Y坐标,0
Right As Long '相当于ScaleHeight
Bottom As Long '相当于ScaleWidth
End Type
Private Declare Function GetClientRect Lib "user32 " (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Sub Form_Load()
Form1.Width = 8000
Form1.Height = 8000
Picture1.Width = 7250
Picture1.Height = 7750
Dim MyRect As RECT
wndCapH = 0 '标题栏高
wndEdgeX = 0 '边框厚度
wndEdgeY = 0 '边框高度
GetClientRect Me.hwnd, MyRect
wndCapH = GetSystemMetrics(4)
Picture1.Left = (Form1.Width - MyRect.Right * 15) / 2
Picture1.Top = (Form1.Height - wndCapH * 15 - MyRect.Bottom * 15) / 2
End Sub
普及小知识(摘抄于网络:https://zhidao.baidu.com/question/184933099.html)
- 缇(Twips) ,计量单位。1厘米有 567 缇。
- 像素(Pixels):此处指监视器屏幕分辨率的最小单位。
- DPI的意思就是 DPI (Dots per Inch)。
- TPI的意思就是 TPI (Twips per Inch)。
- 1 Pixel = 1440 TPI / 96 DPI = 15 Twips。
- 此处1厘米=576/15=37.8像素。