--
'*************************************************************************
'**模 块 名:ModAutoSize
'**说 明:自动调整窗体控件大小及位置
'**创 建 人:嗷嗷叫的老马
'** http://www.m5home.com/
'**日 期:2003年12月17日
'**备 注: 摘于网络
'**版 本:V1.0
'*************************************************************************
'' 在Form_Load里面调用:
'' ControlAutoSize Me,0
'' 在Form_Resize里面调用:
'' ControlAutoSize Me,1
''**********************************
'
Option Explicit
Private Type cP
Wp As Single
Hp As Single
Tp As Single
Lp As Single
End Type
Dim Ap() As cP
Private Sub Ai(ByRef mForm As Form)
On Error Resume Next
Dim I As Integer
For I = 0 To mForm.Controls.Count - 1
With Ap(I)
.Wp = mForm.Controls(I).Width / mForm.Width
.Hp = mForm.Controls(I).Height / mForm.Height
.Lp = mForm.Controls(I).Left / mForm.Width
.Tp = mForm.Controls(I).top / mForm.Height
End With
Next I
End Sub
Public Function ControlAutoSize(ByRef mForm As Form, ByVal OptIndex As Long)
Select Case OptIndex
Case 0
mForm.Height = mForm.ScaleHeight
ReDim Ap(0 To mForm.Controls.Count - 1)
Call Ai(mForm)
Case Else
Dim I As Integer
On Error Resume Next
With mForm
For I = 0 To .Controls.Count - 1
.Controls(I).Move Ap(I).Lp * .ScaleWidth, _
Ap(I).Tp * .ScaleHeight, _
Ap(I).Wp * .ScaleWidth, _
Ap(I).Hp * .ScaleHeight
Next I
End With
End Select
End Function
沒有留言:
張貼留言