解决方案 »

  1.   

    In the Change event of the parent window, resize your child controls accordingly.  You need to decide the relative size (percentage) of all child controls on the window.
      

  2.   

    Option Explicit
    Dim filename As String
    Private FormOldWidth As Long
    '保存窗体的原始宽度
    Private FormOldHeight As Long
    '保存窗体的原始高度'在调用ResizeForm前先调用本函数
    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'按比例改变表单内各元件的大小,在调用ReSizeForm前先调用ReSizeInit函数
    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 DoubleScaleX = 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 IfObj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
    Next i
    Next Obj
    On Error GoTo 0
    End SubPrivate Sub Command1_Click()
    With Form1
    .Dialog1.DialogTitle = "shenmewanyi"
    .Dialog1.filename = "ha"
    .Dialog1.FilterIndex = 2
    .Dialog1.Filter = "*.txt|*.txt|*.jpg|*.jpg|*.mp3|*.mp3"
    .Dialog1.ShowOpen
    filename = Form1.Dialog1.filename
    If filename = "" Then
    MsgBox " kong"
    Else
    MsgBox filename
    End If
    .Picture1.Picture = LoadPicture(filename)
    End With
    End SubPrivate Sub Command2_Click()
    Set Command1.Container = Frame1 'Form1.Picture1
    Command1.Left = 0
    Command1.Top = 0
    End SubPrivate Sub Form_Load()
    Call ResizeInit(Me) '在程序装入时必须加入
    End SubPrivate Sub Form_Resize()
    Call ResizeForm(Me) '确保窗体改变时控件随之改变
    End Sub