Dim FrmW As Single '存放改变前的窗体的宽度
Dim frmH As Single '存放改变前的窗体的高度
Private Sub Form_Load()
If WindowState <> vbMinimized Then
FrmW = Me.Width
frmH = Me.Height
'上面两句是初始化模块变量
End If
End Sub
Private Sub Form_Resize()
If FrmW = 0 Or frmH = 0 Then Exit Sub
Dim MyCon As Control
Dim sig1 As Single, sig2 As Single
sig1 = Me.Width / FrmW
sig2 = Me.Height / frmH
For Each MyCon In Me.Controls
If TypeOf MyCon Is Label Or _
TypeOf MyCon Is CommandButton Or _
TypeOf MyCon Is ListView Or _
TypeOf MyCon Is TextBox Or _
TypeOf MyCon Is Toolbar Or _
TypeOf MyCon Is SSTab Or _
TypeOf MyCon Is PictureBox Or _
TypeOf MyCon Is CheckBox Or _
TypeOf MyCon Is OptionButton Or _
TypeOf MyCon Is Frame Then
With MyCon
' MsgBox .Name
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
.Height = Int(.Height * sig2)
End With
End If
Next MyCon
For Each MyCon In Me.Controls
If TypeOf MyCon Is ComboBox Then
With MyCon
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
End With
End If
Next MyCon
Dim FrmW As Single '存放改变前的窗体的宽度
Dim frmH As Single '存放改变前的窗体的高度
Private Sub Form_Load()
If WindowState <> vbMinimized Then
FrmW = Me.Width
frmH = Me.Height
'上面两句是初始化模块变量
End If
End Sub
Private Sub Form_Resize()
If FrmW = 0 Or frmH = 0 Then Exit Sub
Dim MyCon As Control
Dim sig1 As Single, sig2 As Single
sig1 = Me.Width / FrmW
sig2 = Me.Height / frmH
For Each MyCon In Me.Controls
If TypeOf MyCon Is Label Or _
TypeOf MyCon Is CommandButton Or _
TypeOf MyCon Is ListView Or _
TypeOf MyCon Is TextBox Or _
TypeOf MyCon Is Toolbar Or _
TypeOf MyCon Is SSTab Or _
TypeOf MyCon Is PictureBox Or _
TypeOf MyCon Is CheckBox Or _
TypeOf MyCon Is OptionButton Or _
TypeOf MyCon Is Frame Then
With MyCon
' MsgBox .Name
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
.Height = Int(.Height * sig2)
End With
End If
Next MyCon
For Each MyCon In Me.Controls
If TypeOf MyCon Is ComboBox Then
With MyCon
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
End With
End If
Next MyCon