Office中国论坛/Access中国论坛

标题: 求教关于主窗及控件大小同步缩放问题 [打印本页]

作者: cnffmso    时间: 2009-10-31 10:54
标题: 求教关于主窗及控件大小同步缩放问题
从网上搜集的代码,但在测试时老无法通过,自己无法纠正,紧急求教各位高手!测试的示例见附件!
作者: kangking    时间: 2009-10-31 19:12
你的代码可能是VB的代码,在ACCESS的VBA中行不通。

下面的代码你试试。
Option Compare Database
Dim FrmW As Single '存放改变前的窗体的宽度
Dim frmH As Single '存放改变前的窗体的高度

Private Sub Form_Load()
'If me.windowstate <> vbMinimized Then
FrmW = Me.InsideWidth
frmH = Me.InsideHeight
'上面两句是初始化模块变量
'Form_Resize1
'End If
End Sub
Private Sub Form_Resize()

If FrmW = 0 Or frmH = 0 Then Exit Sub
On Error Resume Next
Dim MyCon As Control
Dim sig1 As Single, sig2 As Single
sig1 = Me.InsideWidth / FrmW
sig2 = Me.InsideHeight / frmH


For Each MyCon In Me.Controls
   

With MyCon
    If .ControlType = 109 Or .ControlType = 100 Or .ControlType = 112 Or .ControlType = 119 Then
        .Left = Int(.Left * sig1)
        .Top = Int(.Top * sig2)
        .Width = Int(.Width * sig1)
        .Height = Int(.Height * sig2)
    End If
End With
Next MyCon

FrmW = Me.InsideWidth
frmH = Me.InsideHeight
End Sub
作者: cnffmso    时间: 2009-11-2 23:04
成功,谢谢kangking的分享
作者: cnffmso    时间: 2009-11-2 23:13
不过高度的变化好像不是很理想




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3