Advertisement
2_2002-2004 Custom Controls/ Forms/ Menus #117638

Center a form, relative to the available workspace

Centers a form, relative to the available workspace. This means that if your users have high, or wide taskbars, or other apps which restrict the workspace, your forms will still center properly.

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
Public Sub Center(ByRef frm As Form)
'Centers a form, relative to the available workspace
Dim rt As RECT, result As Long
Dim X As Single, Y As Single
Dim oldScaleMode As Integer
result = SystemParametersInfo(SPI_GETWORKAREA, 0&, rt, 0&)
X = rt.Right - rt.Left
Y = rt.Bottom - rt.Top
X = X * Screen.TwipsPerPixelX
Y = Y * Screen.TwipsPerPixelY
X = X \ 2 - (frm.Width \ 2)
Y = Y \ 2 - (frm.Height \ 2)
oldScaleMode = frm.ScaleMode
frm.ScaleMode = vbTwips
frm.Move X, Y
frm.ScaleMode = oldScaleMode
End Sub

Upload
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine