使用 InsideWidth 屬性和 InsideHeight 屬性可以確定包含窗體的窗口的高度和寬度(以緹為單位)。Long 型,可讀寫(xiě)。
expression.InsideWidth
expression 必需。返回“應(yīng)用于”列表中的一個(gè)對(duì)象的表達(dá)式。
InsideHeight 屬性和 InsideWidth 屬性僅在使用宏或 Visual Basic 時(shí)才可用,并且可以在任何時(shí)候進(jìn)行設(shè)置。
如果要確定窗體本身的內(nèi)部尺寸,可以使用 Width 屬性來(lái)確定窗體的寬度,并使用窗體的可見(jiàn)節(jié)的高度之和來(lái)確定窗體的高度(Height 屬性只應(yīng)用于窗體節(jié),而不是窗體)。窗體的內(nèi)部是指窗體內(nèi)的區(qū)域,不包括滾動(dòng)條和記錄選定器。
也可以使用 WindowHeight 和 WindowWidth 屬性來(lái)確定包含窗體的窗口的高度和寬度。
如果一個(gè)窗口處于最大化狀態(tài),那么對(duì)這些屬性進(jìn)行的設(shè)置只有在窗口恢復(fù)為正常大小時(shí)才起作用。
下面的示例顯示如何使用 InsideHeight 屬性和 InsideWidth 屬性對(duì)窗體的內(nèi)部高度、內(nèi)部寬度和包含窗體的窗口的高度、寬度進(jìn)行比較。如果窗口與窗體大小不相等,則重新設(shè)置窗口的大小,使其與窗體的高度和寬度相一致。
Sub ResetWindowSize(frm As Form)
Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
Dim intTotalFormHeight As Integer
Dim intTotalFormWidth As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer
' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height
intHeightDetail = frm.Section(acDetail).Height
intHeightFooter = frm.Section(acFooter).Height
intTotalFormHeight = intHeightHeader _
+ intHeightDetail + intHeightFooter
' Determine form's width.
intTotalFormWidth = frm.Width
' Determine window's height and width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth
If intWindowWidth <> intTotalFormWidth Then
frm.InsideWidth = intTotalFormWidth
End If
If intWindowHeight <> intTotalFormHeight Then
frm.InsideHeight = intTotalFormHeight
End If
End Sub