|
|
Выравнивание Элементов Управления по горизонтали
Public Sub EqvGorizontal(frm As Form, ctrl As Control, iTotControls%, iControlNo%, _
Optional iMinFormWidthCm As Currency = 0)
Const TwipsInCM = 567
Dim iLeft%, iTop%
Dim iWidth%, iHeight%
Dim iNewFormWidth%
Dim i As Integer
Static iMinLeft%
Static iBetweenLen%
On Error GoTo EqvGorizontal_Err
iNewFormWidth = frm.InsideWidth
i = iMinFormWidthCm * TwipsInCM + i
If iNewFormWidth < i Then GoTo EqvGorizontal_End
If iControlNo = 1 Then
iMinLeft = ctrl.Left
i = iNewFormWidth - (ctrl.Width + iMinLeft)
iBetweenLen = (i - iMinLeft) \ (iTotControls - 1)
GoTo EqvGorizontal_End
End If
If iControlNo > 1 And iMinLeft = 0 Then GoTo EqvGorizontal_End
iTop = ctrl.Top
iWidth = ctrl.Width
iHeight = ctrl.Height
iLeft = iMinLeft + (iBetweenLen * (iControlNo - 1))
ctrl.Move iLeft, iTop, iWidth, iHeight
EqvGorizontal_End:
On Error GoTo 0
Exit Sub
EqvGorizontal_Err:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure EqvGorizontal.", vbCritical, "Произошла ошибка!"
Err.Clear
Resume EqvGorizontal_End
End Sub
Из этого:
это:
После изменения размера ...
MSA-2003 ( 27 kB) Пример
|
|