例如, 窗体中仅存在一个 TextBox 控件
如下代码:Text1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight这样能使控件适应窗体的大小那么反过来, 要改变窗体大小来适应控件, 应该怎么做?当然, 例如 Me.Width = Text1.Width + 10
这样大致可以达到预期的效果,
但我想知道有没有比较精确的方法.请大家指点, 谢谢.
如下代码:Text1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight这样能使控件适应窗体的大小那么反过来, 要改变窗体大小来适应控件, 应该怎么做?当然, 例如 Me.Width = Text1.Width + 10
这样大致可以达到预期的效果,
但我想知道有没有比较精确的方法.请大家指点, 谢谢.
'ScaleMode 为像素
Dim X As Double
Dim Y As DoubleX = Me.Width / Screen.TwipsPerPixelX - Me.ScaleWidth
Y = Me.Height / Screen.TwipsPerPixelY - Me.ScaleHeightText1.Move 0, 0Me.Width = (Text1.Width + X) * Screen.TwipsPerPixelX
Me.Height = (Text1.Height + Y) * Screen.TwipsPerPixelY
给把分给自己不啊?