网络开发 调用API函数 报表打印 常用技术 经验汇总 控件使用 软件工程 数据处理
您的位置:首页 >> vfp教程 >> 网上文摘 >> 常用技术 >> 正文

让程序自动去响应MSGBOX的确认操作
出处:网络

*-- 文章标题:让程序自动去响应MSGBOX的确认操作
*-- 程序说明:建立一个MESSAGEBOX对话框,当没有用户去响应时,自动在一定时间内响应回车事件
*-- 原作:Matt Weinbender SoftServ, Inc. 5/3/2000
*-- 由红虎简化该程序
*-- 使用:MsgBoxTmr("对话框信息","对话框标题",按纽类型(参考messagebox()帮助),等待时间(单位:秒))
*-- 返回: 同messagebox()一样
*-- 注意: 如果在 VFP5 中运行,需要 FoxTools.FLL
*--如果在 VFP6 中,就无需了。

FUNCTION MsgBoxTmr
*-- 接受参数,最多4个
LPARAMETERS lcMsgText, lcMsgTitle, lnButtons, lnWaitSecs

*-- 检查传递的参数
*-- 等待时间必须大于等于0,如果等于0,为不等待
if type("lnWaitSecs") # "N"
lnWaitSecs = 0
else
if lnWaitSecs < 0
lnWaitSecs = 0
endif
endif

*-- 按纽类型为,0,1,1+16,2+32+256...等形式
if type("lnButtons") # "N"
lnButtons = 0
endif

*-- 标题为字符,默认用主窗口标题
if type("lcMsgTitle") # "C"
lcMsgTitle = _screen.caption
endif

*-- 信息内容为字符
if type("lcMsgText") # "C"
lcMsgText?= "无提示信息"
endif

*-- 创建时钟对象?
do definetimer
oEnterWait = CreateObject'EnterTimeOut')
oEnterWait.Interval = (lnWaitSecs * 1000)
oEnterWait.Enabled?= .T.

*-- 提示对话框
lnRetVal = MessageBox( lcMsgText, lnButtons, lcMsgTitle)
oEnterWait.Enabled = .F.
release all like oEnterWait
retu lnRetVal

*-- 定义时钟对象
Proc definetimer
Define Class EnterTimeOut AS timer
Enabled = .F.
Interval = 20
Procedure timer
keyboard '{ENTER}' plain
Endproc
Enddefine
Endproc

[返回]

     

首页 | 设为首页 | 加入收藏 | 关于本站 | 友情链接 | 版权声明

     
 
Copyright© www.bianceng.cn Powered by 编程入门网 All Rights Reserved
吉ICP备06005558号