InsideWidth 属性

expandtri全部显示

使用 InsideWidth 属性和 InsideHeight 属性可以确定包含窗体的窗口的高度和宽度(以为单位)。Long 型,可读写。

expression.InsideWidth

expression     必需。返回“应用于”列表中的一个对象的表达式。

说明

InsideHeight 属性和 InsideWidth 属性仅在使用Visual Basic 时才可用,并且可以在任何时候进行设置。

如果要确定窗体本身的内部尺寸,可以使用 Width 属性来确定窗体的宽度,并使用窗体的可见节的高度之和来确定窗体的高度(Height 属性只应用于窗体节,而不是窗体)。窗体的内部是指窗体内的区域,不包括滚动条和记录选定器

也可以使用 WindowHeightWindowWidth 属性来确定包含窗体的窗口的高度和宽度。

如果一个窗口处于最大化状态,那么对这些属性进行的设置只有在窗口恢复为正常大小时才起作用。

示例

下面的示例显示如何使用 InsideHeight 属性和 InsideWidth 属性对窗体的内部高度、内部宽度和包含窗体的窗口的高度、宽度进行比较。如果窗口与窗体大小不相等,则重新设置窗口的大小,使其与窗体的高度和宽度相一致。

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