| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1367 人关注过本帖
标题:Pb中idle事件的用处及idle(N)函数的用法:
只看楼主 加入收藏
hzjwcx
Rank: 2
等 级:新手上路
威 望:3
帖 子:60
专家分:0
注 册:2006-12-18
收藏
 问题点数:0 回复次数:1 
Pb中idle事件的用处及idle(N)函数的用法:

功能该函数在用户每次活动(例如,按键盘、移动鼠标等)后重置定时器,n秒后触发应用对象的Idle事件。
语法Idle ( n )
参数n:指定空闲时间间隔,以秒为单位。该参数的值设置为0时,停止空闲检测,不再触发应用对象的Idle事件返回值Integer。函数执行成功时返回1,此时启动定时器。如果不能启动定时器或定时器未启动而n的值指定为0时,函数返回-1。如果任何参数的值为NULL,Idle()函数返回NULL。用法利用Idle()函数,应用程序可以构造自己的屏幕保护程序,避免安全数据的泄露。当使用Idle()函数已经启动了定时器后,如果再次以非0参数调用Idle()函数,那么该函数重设时间间隔,但并不启动新的定时器。Idle()函数启动定时器后,如果在指定的时间间隔(从用户最近一次操作算起)内没有操作应用程序,那么就触发应用对象的Idle事件,在这个事件中可以编写关闭窗口、退出数据库登录等一系列代码,然后使用Restart()函数重新启动应用程序,起到保密的目的。发生下述任何情况时,系统自动重置定时器(即重新开始计时):n 用户在该应用程序的任何窗口内移动鼠标或单击鼠标(双击鼠标时首先触发单击事件)n 在该应用程序的某个窗口是当前窗口时用户按下了任意一个或多个键n 在该应用程序的窗口最小化时,用户在该应用的图标上单击鼠标或移动鼠标n 在该应用程序的窗口最小化并且该应用程序是当前应用程序(应用名称被加亮显示)时,用户按了任何按键n 可视数据窗口检索数据时引起的编辑控件(指漂浮在数据窗口当前行/列上的编辑控件)

Idle event:
Description
Occurs when the Idle function has been called in an application object script and the specified number of seconds have elapsed with no mouse or keyboard activity.
Event ID
Event ID Objects
None Application
Arguments
None
Return value
None (do not use a RETURN statement)

For examples:
This statement in an application script causes the Idle event to be triggered after 300 seconds of inactivity:
Idle(300)
In the Idle event itself, this statement closes the application:
HALT CLOSE

Idle PowerScript function:
Description
Sets a timer so that PowerBuilder triggers an Application Idle event when there has been no user activity for a specified number of seconds.
Syntax
Idle ( n )
Argument Description
n The number of seconds of user inactivity allowed before PowerBuilder triggers an Application Idle event. A value of 0 terminates Idle detection.
Return value
Integer. Returns 1 if it starts the timer, and -1 if it cannot start the timer or n is 0 and the timer has not been started. Note that when the timer has been started and you change n, Idle does not start a new timer; it resets the current timer interval to the new number of seconds. If n is NULL, Idle returns NULL. The return value is usually not used.
Usage
Use Idle to shut off or restart an application when there is no user activity. This is often done for security reasons.

Idle starts a timer after each user activity (such as, a keystroke or a mouse click), and after n seconds of inactivity it triggers an Idle event. The Idle event script for an application typically closes some windows, logs off the database, and exits the application or calls the Restart function.
The timer is reset when any of the following activities occur:

<1>A mouse movement or mouse click in any window of the application
<2>Any keyboard activity when a window of the PowerBuilder application is current
<3>A mouse click or any mouse movement over the icon when a PowerBuilder application is minimized
<4>Any keyboard activity when the PowerBuilder application is minimized and is current (its name is highlighted)
<5>Any retrieval on a visible DataWindow that causes the edit control to be painted

Tip To capture movement, write script in the MouseMove or Key events of the window or sheet. (Keyboard activity does not trigger MouseMove events.) Disable the DataWindow control and tab ordering during iterative retrieves so the Idle timer is not reset.
his statement sends an Idle event after five minutes of inactivity:

Idle(300)

This statement turns off idle detection:

Idle(0)

This example shows how to use the Idle event to stop the application and restart it after two minutes of inactivity. This is often used for computers that provide information in a public place.
Include this statement in the script for the application's Open event:

Idle(120) // Sends an Idle event after 2 minutes.

Include these statements in the script for the application's Idle event to terminate the application and then restart it:

// Statements to set the database to the desired

// state
...
Restart() // Restarts the application

搜索更多相关主题的帖子: 函数 idle 用法 用处 Idle 
2007-01-11 14:09
hzjwcx
Rank: 2
等 级:新手上路
威 望:3
帖 子:60
专家分:0
注 册:2006-12-18
收藏
得分:0 

没有一个人d

还是自己d吧


2007-01-13 17:36
快速回复:Pb中idle事件的用处及idle(N)函数的用法:
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013964 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved