Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-窗体/数据页

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

时 间:2007-10-21 10:17:35
作 者:gfuuyygy   ID:70  城市:闵行
摘 要:[分享]窗体内的控件与窗体大小同步变化!
正 文:

本示例作者是谁,不记得了,不过试过后很实用的;有一点,只记得原码是加密的,还请各位版主不要宣传!

一:建一模块
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交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助