|
|
Элементы формы - Расширение стобцов пропорционально ширине формы (ленточной)
"Красиво" ресайзим контролли под тек. размер формы.
употребимо при развороте формы в полный экран или при разрешеении юсеру "ресайзить" форму.
MSA 2003 SP1 1280x1024 (в полный экран):
MSA 2003 SP1 1280x1024 (нормальное окно):
MSA 2010 1920x1200 (в полный экран):
Главная форма:
Private Sub Form_Load()
DoCmd.Maximize
End Sub
Private Sub Form_Resize()
Const cm = 567
Dim iMinFormWidth As Integer
Dim iMinFormHeight As Integer
Dim iNewFormWidth As Integer
Dim iNewFormHeight As Integer
Dim l As Integer
Dim t As Integer
Dim w As Integer
Dim h As Integer
Dim iMid As Integer
Dim iTemp As Integer
On Error GoTo Form_ResizeErr
iMinFormWidth = 23 * cm
iMinFormHeight = 10 * cm
iNewFormWidth = Me.InsideWidth
iNewFormHeight = Me.InsideHeight
iTemp = Me!lblHeeader.Left
Me!lblHeeader.Width = iNewFormWidth - iTemp
Me!imgFormHeaderFon.Width = iNewFormWidth
iMid = Round(iNewFormWidth / 2, 0)
iTemp = Round(Me!txtTextToSearch.Width / 2, 0)
t = Me!txtTextToSearch.Top
l = iMid - iTemp
w = Me!txtTextToSearch.Width
h = Me!txtTextToSearch.Height
Me!txtTextToSearch.Move l, t, w, h
w = Me!lblTextToSearch.Width
l = l - Round(2 * cm, 0)
Me!lblTextToSearch.Move l, t, w, h
l = Me!txtTextToSearch.Left + Me!txtTextToSearch.Width + 60
w = cmdClearSearch.Width
Me!cmdClearSearch.Move l, t, w, h
l = iNewFormWidth - Me!cmdClose.Width - 100
Me!cmdClose.Left = l
Me!imgFormFooterFon.Width = iNewFormWidth
iTemp = Round(Me!lblTabToS.Width / 2, 0)
l = iMid - iTemp
Me!lblTabToS.Left = l
l = 0
t = Me!objSubForm.Top
w = iNewFormWidth
iTemp = Me.objFormHeader.Height + Me.objFormFooter.Height + t
h = iNewFormHeight - iTemp
Me!objSubForm.Move l, t, w, h
Form_ResizeBye:
Exit Sub
Form_ResizeErr:
If Err = 2100 Then
Err.Clear
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ")" & vbCrLf & _
"in procedure Form_Resize ", vbCritical, "Error!"
End If
Resume Form_ResizeBye
End Sub
Private Sub Form_Resize()
Const cm = 567
Dim iNewFormWidth As Integer
Dim xPlus As Integer
Dim wPlus As Integer
Dim l As Integer
Dim w As Integer
Dim iMinFormWidth As Integer: iMinFormWidth = CInt(19 * cm)
Dim iTypeNameWidth As Integer: iTypeNameWidth = CInt(3 * cm)
Dim iManNameWidth As Integer: iManNameWidth = CInt(4 * cm)
Dim iGoodNameWidth As Integer: iGoodNameWidth = CInt(6 * cm)
Dim iGoodDescriptionWidth As Integer: iGoodDescriptionWidth = CInt(4 * cm)
On Error GoTo Form_Resize_Err
w = Me.CurrentSectionLeft
iNewFormWidth = Me.InsideWidth - w
If iNewFormWidth <= iMinFormWidth Then GoTo Form_Resize_Bye
With Me
xPlus = iNewFormWidth - iMinFormWidth
If xPlus > 4 Then
wPlus = CInt(xPlus / 4)
Else
wPlus = 0
End If
w = iNewFormWidth - !UnderLine.Left
!UnderLine.Width = w
l = !txtTypeName.Left
w = iTypeNameWidth + wPlus
!txtTypeName.Left = l
!txtTypeName.Width = w
!lblTypeName.Left = l
!lblTypeName.Width = w
l = l + w
w = iManNameWidth + wPlus
!txtManName.Left = l
!txtManName.Width = w
!lblManName.Left = l
!lblManName.Width = w
l = l + w
w = iGoodNameWidth + wPlus
!txtGoodName.Left = l
!txtGoodName.Width = w
!lblGoodName.Left = l
!lblGoodName.Width = w
l = l + w
w = !txtGoodPrice.Width
!txtGoodPrice.Left = l
!txtGoodPrice.Width = w
!lblGoodPrice.Left = l
!lblGoodPrice.Width = w
l = l + w
w = iNewFormWidth - l
w = w - 4
!txtGoodDescription.Left = l
!txtGoodDescription.Width = w
!lblGoodDescription.Left = l
!lblGoodDescription.Width = w
End With
Form_Resize_Bye:
Exit Sub
Form_Resize_Err:
Debug.Print "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in procedure Form_Resize"
Resume Form_Resize_Bye
End Sub
MSA-2003 ( 123 kB)
|
|