vfp自动调整屏幕

时间:2023-04-12 05:17:16 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

自动调整屏幕大小

标签: 分辨率 自动 屏幕

2006-10-29 19:38 阅读(1294)评论(0)

-- 自动调整屏幕大小

*-- 函数 sysmetric(n)

*-- 参数含义及返回值

* 1 当前屏幕宽度

* 2 当前屏幕高度 

*-- 如果当前屏幕的宽度不是预先在设计模式下设定的宽度,则进行对表单上控件的自动调整

*-- 注释: _DesignWidth 和 _DesignHeight 是人为设定的程序运行的默认窗口大小 

IF SYSMETRIC(1) <> This._DesignWidth 

#DEFINE nHeightFactor SYSMETRIC(2) / This._DesignHeight && 默认为 480

#DEFINE nWidthFactor SYSMETRIC(1) / This._DesignWidth && 默认为 640 

WITH THIS

*-- 重新调整表单的大小和位置

.Width = .Width * nWidthFactor

.Height = .Height * nHeightFactor

.Left = .Left * nWidthFactor

.Top = .Top * nHeightFactor 

*-- 重新调整表单上的控件的大小和位置

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事件是有用的,若将This._DesignWidth改为640,将This._DesignHeight改为480,设AUTOCENTER=.f.效果非常明显

分享到:

本文来源:https://www.wddqw.com/doc/98eeb56e5a8102d276a22fe0.html