Private FormOldWidth As Long Private FormOldHeight As Long
Public Sub ResizeInit(ByVal FormName As Form) Dim Obj As Control FormOldWidth = FormName.Size.Width FormOldHeight = FormName.Size.Height On Error Resume Next For Each Obj In FormName.Controls Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " " Next Obj On Error GoTo 0
End Sub
Public Sub ResizeForm(ByVal 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 Double
ScaleX = FormName.Size.Width / FormOldWidth ScaleY = FormName.Size.Height / FormOldHeight
On Error Resume Next
For Each Obj In FormName.Controls 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 If
Obj.Left = Pos(0) * ScaleX Obj.Top = Pos(1) * ScaleY Obj.Width = Pos(2) * ScaleX Obj.Height = Pos(3) * ScaleY
Next i Next Obj On Error GoTo 0
End Sub
在调用的时候,如下:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize Call ResizeForm(Me) End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call ResizeInit(Me) End Sub
|
|
CALENDER
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
28 | 29 | 30 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
留言簿(3)
随笔分类
随笔档案
文章分类
搜索
最新评论
Powered By: 博客园 模板提供:沪江博客
|