|
本帖最后由 一指禅62 于 2015-1-21 21:18 编辑
- Option Explicit
- Dim frmW, frmH
- Dim i
- Private Sub Form_Load()
- If WindowState <> vbMaximized Then
- frmW = Me.Width
- frmH = Me.Height
- End If
- For i = 0 To Ms1.Cols - 1
- Ms1.ColWidth(i) = Int((Ms1.Width - 360) / Ms1.Cols)
- Next
- End Sub
- Private Sub Form_Resize()
- On Error Resume Next
- If frmW = 0 Or frmH = 0 Then Exit Sub
- Dim c As Control, x, y
- x = Me.Width / frmW
- y = Me.Height / frmH
- For Each c In Me.Controls
- With c
- .Left = Int(.Left * x)
- .Top = Int(.Top * y)
- .Width = Int(.Width * x)
- .Height = Int(.Height * y)
- End With
- Next
- For i = 0 To Ms1.Cols - 1
- Ms1.ColWidth(i) = Int(Ms1.ColWidth(i) * x)
- Next
- frmW = Me.Width
- frmH = Me.Height
- End Sub
复制代码 vba 的 UserForm_Initialize 事件- Private Sub UserForm_Initialize()
- Dim k As Object, x, y
- With Application
- .WindowState = xlMaximized
- x = .Width / Me.Width
- y = .Height / Me.Height
- For Each k In Me.Controls
- k.Move k.Left * x, k.Top * y, k.Width * x, k.Height * y
- Next
- Me.Move .Left, .Top, .Width, .Height
- End With
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|