☆灰色轨迹☆

量身定制开发各种管理软件,如:人事管理,客户管理,库存管理,POS系统,进销存管理等各种管理软件,有需要的请联系QQ:543169042...

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
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lijianhe043/article/details/6885336
个人分类: pb知识库
想对作者说点什么? 我来说一句

PB9多Timer事件实例

2011年11月25日 18KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭