[分享]窗体内的控件与窗体大小同步变化!
时 间: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源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access选项卡示例】Ac...(09.09)
- 【Access源码示例】按输入...(09.02)
- 【Access日期区间段查询】...(08.29)
- 【Access日期区间段查询】...(08.27)
- Access怎样才能实现日期时...(08.21)
- 【Access定时打开查询】A...(08.19)
- Access生成固定数量的记录...(08.13)
- Access怎样才能实现日期时...(08.12)
- Access利用导航窗体控件对...(08.03)
学习心得
最新文章
- Access表中的字段名、字段标题...(09.19)
- Access快速开发平台--更改“...(09.18)
- 【中秋及国庆优惠】Access培训...(09.15)
- Access如何将日期型的数值转换...(09.14)
- 英文输入法输入数据中存在单引号引起...(09.11)
- 【Access选项卡示例】Acce...(09.09)
- 让Access光标停留在指定的控件...(09.07)
- 关于Access查询条件里使用通配...(09.06)
- Access报表偷懒制作法--Ac...(09.05)
- Access快速开发平台--窗体数...(09.04)