VB按比例改变自身控件大小

RT... RT 展开
 我来答
sk傷
2011-03-29 · 超过31用户采纳过TA的回答
知道答主
回答量:108
采纳率:0%
帮助的人:0
展开全部
Option Explicit
Private FormOldWidth As Long
Private FormOldHeight As Long
Public Sub ResizeInit(FormName As Form)
Dim Obj As Control
FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight
On Error Resume Next
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
On Error GoTo 0
End Sub

Public Sub ResizeForm(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.ScaleWidth / FormOldWidth
ScaleY = FormName.ScaleHeight / FormOldHeight
On Error Resume Next
For Each Obj In FormName
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.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Next i
Next Obj
On Error GoTo 0
End Sub

Private Sub Form_Load()
Call ResizeInit(Me)
End Sub

Private Sub Form_Resize()
Call ResizeForm(Me)
End Sub
xuanxuan163com
2011-03-29 · TA获得超过2769个赞
知道大有可为答主
回答量:1709
采纳率:75%
帮助的人:1599万
展开全部
改变Form1上控件大小,宽放大m倍,高放大n倍
Private Sub fangda()
Dim myControl As Control
Dim m As Single, n As Single
m = 1.5
n = 1.2
For Each myControl In Form1.Controls
myControl.Move myControl.Left, myControl.Top, myControl.Width * m, myControl.Height * n
Next
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式