OK l know about the Left and top commands and have used these successfully. Does anyone know how to take into account the task bar when positioning a form, so that the form is centered in the "available" window space. Thanks in advance
Printable View
OK l know about the Left and top commands and have used these successfully. Does anyone know how to take into account the task bar when positioning a form, so that the form is centered in the "available" window space. Thanks in advance
Try this:
Usage: CenterForm FormCode:Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXFULLSCREEN = 16
Private Const SM_CYFULLSCREEN = 17
Public Sub CenterForm(pForm As Form)
Dim lngLeft As Long, lngTop As Long
lngLeft = (Screen.TwipsPerPixelX * (GetSystemMetrics(SM_CXFULLSCREEN) / 2)) - (pForm.Width / 2)
lngTop = (Screen.TwipsPerPixelY * (GetSystemMetrics(SM_CYFULLSCREEN) / 2)) - (pForm.Height / 2)
pForm.Move lngLeft, lngTop
End Sub
Example: CenterForm Me
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 02-22-2000).]