Postup:
Sub CenterFormWithParent(aForm As Form, aParent As Form)
aForm.Left = aParent.Left + (aParent.Width - aForm.Width) / 2
aForm.Top = aParent.Top + (aParent.Height - aForm.Height) / 2
If (aForm.Left + aForm.Width) > Screen.Width Then
aForm.Left = Screen.Width - aForm.Width
Else
If aForm.Left < 0 Then aForm.Left = 0
End If
If (aForm.Top + aForm.Height) > Screen.Height Then
aForm.Top = Screen.Height - aForm.Height
Else
If aForm.Top < 0 Then aForm.Top = 0
End If
End Sub
Tuhle proceduru pou₧ijte na udßlost Form_Load u formulß°e, kter² chcete
vycentrovat (aFomr) vzhledem k formulß°i, kter² jej vyvolßvß (aParent).
|