vb怎么才能使窗口最大化时候其他控件怎么一起变大
以前有个大神发了代码但是怎么有错误,想再问一下程序代码:
Option Explicit Private InitWidth As Long ' Form 的原始大小 Private InitHeight As Long Private Sub Form_Load() InitWidth = ScaleWidth InitHeight = ScaleHeight Dim Ctl As Control ' 记录每个 Control 的原始位置、大小、字型大小, 放在 Tag 属性中 On Error Resume Next '确保left, top, width, height, Tag属性没有全有的Control For Each Ctl In Me '也能正常执行 Ctl.Tag = Ctl.Left & " " & Ctl.Top & " " & Ctl.Width & " " & Ctl.Height & " " Ctl.Tag = Ctl.Tag & Ctl.FontSize & " " Next Ctl On Error GoTo 0 End Sub Private Sub Form_Resize() Dim D(4) As Double Dim I As Long Dim TempPos As Long Dim StartPos As Long Dim Ctl As Control Dim TempVisible As Boolean Dim ScaleX As Double Dim ScaleY As Double ScaleX = ScaleWidth / InitWidth ScaleY = ScaleHeight / InitHeight On Error Resume Next For Each Ctl In Me TempVisible = Ctl.Visible Ctl.Visible = False StartPos = 1 ' 读取 Control 的原始位置、大小、字型大小 For I = 0 To 4 TempPos = InStr(StartPos, Ctl.Tag, " ", vbTextCompare) If TempPos > 0 Then D(I) = Mid(Ctl.Tag, StartPos, TempPos - StartPos) StartPos = TempPos + 1 Else: D(I) = 0 End If ' 根据比例设定 Control 的位置、大小、字型大小 Ctl.Move D(0) * ScaleX, D(1) * ScaleY, D(2) * ScaleX, D(3) * ScaleY ' Ctl.Width = D(2) * ScaleX ' Ctl.Height = D(3) * ScaleY If ScaleX < ScaleY Then Ctl.FontSize = D(4) * ScaleX Else Ctl.FontSize = D(4) * ScaleY End If Next I Ctl.Visible = TempVisible Next Ctl On Error GoTo 0 End Sub在next ctl处,说没有for
[ 本帖最后由 t469116416 于 2014-3-24 13:27 编辑 ]