我把窗体的WindowState属性设置为了2,运行后,弹出来的窗体是全屏的,但是窗体里的picture和TEXTBOX两个控件还是原来的大小,怎么样才能把picture和textbox的大小也改为全屏模式后的。

解决方案 »

  1.   

    Option Explicit
    Private FormOldWidth As Long
    Private FormOldHeight As Long
    Public Sub ResizeInit(FormName As Form)
    Dim Obj As Control
    FormOldWidth = FormName.ScaleWidth
    FormOldHeight = FormName.ScaleHeight
    On Error Resume Next
    For Each Obj In FormName
    Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
    Next Obj
    On Error GoTo 0
    End Sub
    Public Sub ResizeForm(FormName As Form)
    Dim pos(4) As Double
    Dim I As Long, TempPos As Long, StartPos As Long
    Dim Obj As Control
    Dim ScaleX As Double, ScaleY As Double
    ScaleX = FormName.ScaleWidth / FormOldWidth
    ScaleY = FormName.ScaleHeight / FormOldHeight
    On Error Resume Next
    For Each Obj In FormName
    StartPos = 1
    For I = 0 To 4
    TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
    If TempPos > 0 Then
    pos(I) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
    StartPos = TempPos + 1
    Else
    pos(I) = 0
    End If
    Obj.Move pos(0) * ScaleX, pos(1) * ScaleY, pos(2) * ScaleX, pos(3) * ScaleY
    Next I
    Next Obj
    On Error GoTo 0
    End Sub
      

  2.   

    控件的left,top,width,height.
      

  3.   

    在Form_resize事件中自己写代码, 改变控件的大小.给你个小提示:
    不要width, height, top, left等等属性一个一个改, 
    通过控件自带的move方法一次性指定上面四个属性更快.