2,749
社区成员
发帖
与我相关
我的任务
分享*-- 在表单中新建一个方法forminit,代码如下:
*-- 注释: _DesignWidth 和 _DesignHeight 是人为设定的程序运行的默认窗口大小
_DesignHeight = 480 && 默认为 480,可以根据情况修改为600或768
_DesignWidth = 640 && 默认为 640,可以根据情况修改为800或1024
If Sysmetric(1)<>_DesignWidth
nHeightFactor = Sysmetric(2) / _DesignHeight
nWidthFactor = Sysmetric(1) / _DesignWidth
With This
*-- 重新调整表单的大小和位置
nNewWidth = .Width * nWidthFactor
nNewHeight = .Height * nHeightFactor
If .AutoCenter = .T.
nNewWidth = .Width * nWidthFactor
nNewHeight = .Height * nHeightFactor
.Left = .Left - (nNewWidth - .Width)/2
.Top = .Top - (nNewHeight - .Height)/2
.Width = nNewWidth
.Height = nNewHeight
Else
.Left = .Left * nWidthFactor
.Top = .Top * nHeightFactor
.Width = nNewWidth
.Height = nNewHeight
Endif
*-- 重新调整表单上的控件的大小和位置
For nControlLoop = 1 To .ControlCount
.Controls[nControlLoop].Width = .Controls[nControlLoop].Width * nWidthFactor
.Controls[nControlLoop].Height = .Controls[nControlLoop].Height * nHeightFactor
.Controls[nControlLoop].Left = .Controls[nControlLoop].Left * nWidthFactor
.Controls[nControlLoop].Top = .Controls[nControlLoop].Top * nHeightFactor
*-- 调整控件字体大小
If Pemstatus(.Controls[nControlLoop], "FontSize ",5)
.Controls[nControlLoop].FontSize = Int(.Controls[nControlLoop].FontSize * nHeightFactor)
Endif
Endfor
Endwith
Endif
*-- 然后在表单的 Init 事件写上 Thisform.Forminit就可以了。