Resizing a form

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

I am trying to resize the form and have a list view grow
proportionately to the form adn have buttons move withe
the resizing. What i think is the problem is that the
subtraction isn't always right. Here is the code that I
am using:

Private Sub Form_Resize()
Dim screensize As String
screensize = Form_frmShipmentList.WindowWidth

If screensize < 6600 Then
lsvShipments.Width = screensize - 500
Else
lsvShipments.Width = screensize - 500
cmdRefresh.Left = screensize - 3250
cmdClose.Left = screensize - 2000
End If
End Sub
 
hi Kevin,
I am trying to resize the form and have a list view grow
proportionately to the form adn have buttons move withe
the resizing.

The following solution is my best, but not the best, cause the width
problem (unnecessary vertical scrollbar) is still unsolved.

The two vars are form local, SF is a subform, B is an abort button at
the right bottom of the subform:

Private pvInnerHeight As Long
Private pvInnerWidth As Long

Private Sub Form_Load()

pvInnerHeight = Me.Form.WindowHeight -
Me.Form.Section(acHeader).Height - Me.Section(acFooter).Height
pvInnerWidth = Me.Form.WindowWidth

End Sub

Private Sub Form_Resize()

Dim NewHeight As Long
Dim NewWidth As Long
Dim OldHeight As Long
Dim OldWidth As Long

NewHeight = Me.Form.Section(acDetail).Height + (Me.Form.WindowHeight
- Me.Form.Section(acHeader).Height - Me.Section(acFooter).Height) -
pvInnerHeight
NewWidth = Me.Form.WindowWidth
OldHeight = Me.Form.Section(acDetail).Height
OldWidth = pvInnerWidth

If OldHeight < NewHeight Then
Me.Form.Section(acDetail).Height = NewHeight
SF.Height = SF.Height + NewHeight - OldHeight
Else
SF.Height = SF.Height + NewHeight - OldHeight
Me.Form.Section(acDetail).Height = NewHeight
End If

SF.Width = SF.Width + (NewWidth - OldWidth)
B.Left = SF.Left + SF.Width - B.Width

pvInnerHeight = Me.Form.WindowHeight -
Me.Form.Section(acHeader).Height - Me.Section(acFooter).Height
pvInnerWidth = Me.Form.WindowWidth

End Sub

Btw, the subform can also be a page control or etc.

If you or anyone has an solution for the scrollbar, tell me.

--> stefan <--
 
Back
Top