在form的resize事件里,可以实现控件大小与窗体同步缩放。
但是如果把一一些控件放到容器里如frame里,直接对容器操作,容器里的控件大小就不会改变。
怎么实现容器里的控件大小随之改变??
还有,怎么实现字体的大小也随之变化呢?
在不同的分辨率下,看起来效果不变,又怎么实现呢?
但是如果把一一些控件放到容器里如frame里,直接对容器操作,容器里的控件大小就不会改变。
怎么实现容器里的控件大小随之改变??
还有,怎么实现字体的大小也随之变化呢?
在不同的分辨率下,看起来效果不变,又怎么实现呢?
Frame1.Move 0, 0, Me.Width / 2, Me.Height / 2
Text1.Move 0, 0, Frame1.Width, Frame1.Height
End Sub字体的放大缩小只能用字号了
If Me.WindowState = 0 Then
Me.Height = IIf(Me.Height < 3600, 3600, Me.Height)
Me.Width = IIf(Me.Width < 4800, 4800, Me.Width)
End If
End Sub
If g(0) = 0 Then '原始值只記錄一次
g(0) = Fsy1.ScaleWidth: g(1) = Fsy1.ScaleHeight '一開始表單的大小
ReDim a(Fsy1.Controls.Count - 1, 5)
j = 0
For Each i In Fsy1.Controls '記錄每個物件的資料
a(j, 0) = i.Name
On Error Resume Next '避免某些物件沒有指定的屬性而錯誤
a(j, 1) = i.Left: a(j, 2) = i.Top
a(j, 3) = i.Width: a(j, 4) = i.Height
a(j, 5) = i.FontSize
On Error GoTo 0 '取消錯誤處理
j = j + 1
Next i
t = 0: dt = 100
End If
' W1 = Screen.Width \ Screen.TwipsPerPixelX
' If W1 <> 800 Then
' WindowState = 2
' End If
End SubPrivate Sub Form_Resize()
If Fsy1.WindowState <> 1 And g(0) > 0 And g(1) > 0 Then
'重算物件的新位置
For i = 0 To Fsy1.Controls.Count - 1
Set bt = Controls(a(i, 0))
On Error Resume Next
bt.Left = a(i, 1) / g(0) * Fsy1.ScaleWidth
bt.Top = a(i, 2) / g(1) * Fsy1.ScaleHeight
bt.Width = a(i, 3) / g(0) * Fsy1.ScaleWidth
bt.Height = a(i, 4) / g(1) * Fsy1.ScaleHeight
If Fsy1.ScaleWidth / g(0) < Fsy1.ScaleHeight / g(1) Then
bt.FontSize = a(i, 5) / g(0) * Fsy1.ScaleWidth
Else
bt.FontSize = a(i, 5) / g(1) * Fsy1.ScaleHeight
End If
On Error GoTo 0
If TypeOf bt Is PictureBox Then
'If Check1.Value = 1 Then b.PaintPicture b.Picture, 0, 0, b.ScaleWidth, b.ScaleHeight Else b.Cls
End If
Set bt = Nothing
Next i
End If
end sub