Option Explicit Private Const SPI_GETWORKAREA = 48 Private Declare Function SystemParametersInfo& Lib "User32" Alias _ "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As _ Long, lpvParam As Any, ByVal fuWinIni As Long)
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Public Function CenterForm32(frm As Form) Dim ScreenWidth&, ScreenHeight&, ScreenLeft&, ScreenTop& Dim DeskTopArea As RECT Call SystemParametersInfo(SPI_GETWORKAREA, 0, DeskTopArea, 0) ScreenHeight = (DeskTopArea.Bottom - DeskTopArea.Top) * Screen.TwipsPerPixelY ScreenWidth = (DeskTopArea.Right - DeskTopArea.Left) * Screen.TwipsPerPixelX ScreenLeft = DeskTopArea.Left * Screen.TwipsPerPixelX ScreenTop = DeskTopArea.Top * Screen.TwipsPerPixelY frm.Move (ScreenWidth - frm.Width) \ 2 + ScreenLeft, (ScreenHeight - _ frm.Height) \ 2 + ScreenTop End Function
CenterForm32 Me |