大家给看看这段代码!
guowj 2003-05-07 11:03:29 我的以下这段代码为实现窗体控件随窗体的变化而按比例变化,
为什么只有在最大化是可以实现,
其它变化时却达不到效果?
private Sub Form_Load()
fh1 = Form1.Height
fw1 = Form1.Width
End Sub
Private Sub Form_Resize()
Dim scalex, scaley As Integer
Dim fw2, fh2 As Integer
Dim control As Variant
If Form1.WindowState = 1 Then Exit Sub
fw2 = Form1.Width
fh2 = Form1.Height
scalex = fw2 / fw1
scaley = fh2 / fh1
For Each control In Form1.Controls
If (Val(fh2) < fh1) Or (Val(fh2) > fh1) Then
control.Height = control.Height * scaley
control.Top = control.Top * scaley
End If
If (Val(fw2) < fw1) Or (Val(fw2) > fw1) Then
control.Width = control.Width * scalex
control.Left = control.Left * scalex
End If
Next control
fw1 = Form1.Width
fh1 = Form1.Height
End Sub