[分享]窗体内的控件与窗体大小同步变化!-Victor Duane
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-窗体/数据页


[分享]窗体内的控件与窗体大小同步变化!

发表时间:2007/10/21 10:17:35 评论(1) 浏览(7485)  评论 | 加入收藏 | 复制
   
摘 要:[分享]窗体内的控件与窗体大小同步变化!
正 文:
本示例作者是谁,不记得了,不过试过后很实用的;有一点,只记得原码是加密的,还请各位版主不要宣传!

一:建一模块
Public Sub ResizeControls(Formular As Form, ByVal StartFormularbreite As Long, ByVal StartFormularh鰄e As Long)
Dim CHANGE_FACTOR As Double
Dim CHANGE_CONTROL As Control
If Not Formular.WindowWidth = 0 Then
CHANGE_FACTOR = Formular.WindowWidth / StartFormularbreite
If Not CHANGE_FACTOR = 1 Then
On Error Resume Next
If CHANGE_FACTOR > 1 Then
Formular.Section(0).Height = Formular.Section(0).Height * CHANGE_FACTOR
Formular.Section(1).Height = Formular.Section(1).Height * CHANGE_FACTOR
Formular.Section(2).Height = Formular.Section(2).Height * CHANGE_FACTOR
End If
For Each CHANGE_CONTROL In Formular.Controls
If CHANGE_CONTROL.ControlType = acSubform Then
Dim UFOBREITE As Integer
Dim UFOHREITE As Integer
UFOBREITE = CHANGE_CONTROL.Width
UFOHREITE = CHANGE_CONTROL.Height
CHANGE_CONTROL.Width = CHANGE_CONTROL.Width * CHANGE_FACTOR
CHANGE_CONTROL.Height = CHANGE_CONTROL.Height * CHANGE_FACTOR
CHANGE_CONTROL.Top = CHANGE_CONTROL.Top * CHANGE_FACTOR
CHANGE_CONTROL.Left = CHANGE_CONTROL.Left * CHANGE_FACTOR
ResizeControls CHANGE_CONTROL.Form, UFOBREITE, UFOHREITE
Else
CHANGE_CONTROL.Width = CHANGE_CONTROL.Width * CHANGE_FACTOR
CHANGE_CONTROL.Height = CHANGE_CONTROL.Height * CHANGE_FACTOR
CHANGE_CONTROL.Top = CHANGE_CONTROL.Top * CHANGE_FACTOR
CHANGE_CONTROL.Left = CHANGE_CONTROL.Left * CHANGE_FACTOR
CHANGE_CONTROL.FontSize = CHANGE_CONTROL.FontSize * CHANGE_FACTOR
End If
Next

   If CHANGE_FACTOR < 1 Then
Formular.Section(0).Height = Formular.Section(0).Height * CHANGE_FACTOR
Formular.Section(1).Height = Formular.Section(1).Height * CHANGE_FACTOR
Formular.Section(2).Height = Formular.Section(2).Height * CHANGE_FACTOR
End If
Formular.Repaint
On Error GoTo 0
End If
End If
End Sub
二、应用:
Option Compare Database
Option Explicit
Dim Form_Start_Height As Long
Dim Form_Start_Width As Long
Dim Form_Current_Height As Long
Dim Form_Current_Width As Long

Private Sub Form_Open(Cancel As Integer)
Form_Start_Height = Me.WindowHeight
Form_Start_Width = Me.WindowWidth
Form_Current_Height = Me.WindowHeight
Form_Current_Width = Me.WindowWidth
End Sub

Private Sub Form_Resize()
ResizeControls Me, Form_Current_Width, Form_Current_Height
Form_Current_Height = Me.WindowHeight
Form_Current_Width = Me.WindowWidth
End Sub

Access软件网交流QQ群(群号:198465573)
 
 相关文章
【access小品】滑块与控件大小控制  【todaynew  2010/6/30】
access2007\2010小技巧一则---控件自适应窗体、屏幕...  【麥田  2011/10/29】
最简单的动态改变控件大小示例  【彭海涛  2013/12/31】
多个子窗体同步调整尺寸  【在水一方  2014/8/26】
水平定点与垂直定点属性的说明  【缪炜  2014/11/28】
常见问答
技术分类
相关资源
文章搜索
关于作者

Victor Duane

文章分类

文章存档

友情链接