Dim Cntl As Control
Dim SubCntl As Control
Dim subFrm As Form
Dim clColumn As ClassFormSize
Dim clDataSheet As ClassFormSize
Dim clSection As ClassFormSize
Dim clControl As New ClassFormSize
Dim clSubForm As New ClassFormSize
Dim strSub As String
Dim intLoop As Integer
Dim intColCount As Integer
Dim strColWidths As String
Dim intCol As Integer
Dim varColList As Variant
Dim dblColWidth As Double
Dim intColWidth As Integer
Dim strCol As String
Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
' Determine form's width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth
'set the default values for the form
clTopForm.ObjHeight = intWindowHeight
clTopForm.ObjWidth = intWindowWidth
clTopForm.ObjName = frm.Name
'If the form is in datasheet view then do something exciting.
If frm.CurrentView = 2 Then
Set clDataSheet = New ClassFormSize
'Font size.
clDataSheet.ObjFontSize = frm.DatasheetFontHeight
'Row height.
clDataSheet.ObjHeight = frm.RowHeight
'list control names in detail section.
Set clSection = New ClassFormSize
clSection.ObjName = frm.Section(0).Name
For Each Cntl In frm.Section(0).Controls
Set clControl = New ClassFormSize
clControl.ObjName = Cntl.Name
clSection.sAddObject clControl
Set clControl = Nothing
Next
clDataSheet.sAddObject clSection
Set clSection = Nothing
clTopForm.sAddObject clDataSheet
Set clDataSheet = Nothing
Else
'Loop through the sections and controls.
intLoop = 0
Do
'section.
If fHasSection(frm, intLoop) Then
Set clSection = New ClassFormSize
clSection.ObjName = frm.Section(intLoop).Name
clSection.ObjHeight = frm.Section(intLoop).Height
'controls.
For Each Cntl In frm.Section(intLoop).Controls
Set clControl = New ClassFormSize
clControl.ObjName = Cntl.Name
clControl.ObjWidth = Cntl.Width
clControl.ObjHeight = Cntl.Height
clControl.ObjTop = Cntl.Top
clControl.ObjLeft = Cntl.Left
If fHasFontSize(Cntl) Then
clControl.ObjFontSize = Cntl.FontSize
Else
clControl.ObjFontSize = 0
End If
Select Case Cntl.ControlType
Case acSubform
'Get the subform
Set clSubForm = New ClassFormSize
'[Forms]![frmPassword]![tblSecureQuestion].[form]![SecureQuestion].
Set subFrm = Cntl.Form
sReadDefaultSize subFrm, clSubForm
clControl.sAddObject clSubForm
Set clSubForm = Nothing
Set subFrm = Nothing
Case acListBox, acComboBox
'get the columns.
intColCount = Cntl.ColumnCount
If intColCount = 1 Then
Set clColumn = New ClassFormSize
clColumn.ObjName = "Col_0"
clColumn.ObjWidth = Cntl.ColumnWidth
clControl.sAddObject clColumn
Set clColumn = Nothing
Else
strColWidths = Cntl.ColumnWidths
varColList = Split(strColWidths, ";")
For intCol = 0 To intColCount - 1
strCol = varColList(intCol)
If InStr(1, strCol, "in") > 0 Then
dblColWidth = CDbl(Trim(Left(strCol, InStr(1, strCol, "in"))))
intColWidth = CInt(dblColWidth * 1440)
ElseIf InStr(1, strCol, "cm") > 0 Then
dblColWidth = CDbl(Trim(Left(strCol, InStr(1, strCol, "cm"))))
intColWidth = CInt(dblColWidth * 567)
Else
intColWidth = CInt(Trim(strCol))
End If
Set clColumn = New ClassFormSize
clColumn.ObjName = "Col_" & intCol
clColumn.ObjWidth = intColWidth
clControl.sAddObject clColumn
Set clColumn = Nothing
Next
End If
End Select
clSection.sAddObject clControl
Set clControl = Nothing
Next
clTopForm.sAddObject clSection
Set clSection = Nothing
'print the height.
'Debug.Print clTopForm.GetObj("Detail").ObjHeight.
End If
intLoop = intLoop + 1
If intLoop = 3 Then Exit Do
Loop
End If
'Debug.Print "Loaded".
End Sub