HOWTO: Causing a Form or Formset to Time OutID: Q133451 The information in this article applies to:
SUMMARYFoxPro version 2.x provided a TIMEOUT clause on the READ command. If no user input activity occurred during the specified interval, the read operation would stop. You can duplicate this functionality with a timer control on a form in Visual FoxPro. The enhanced event model in Visual FoxPro allows greater control over exactly which events cause a form to time out. For example, you can cause the form to close if the mouse is clicked even though no key was pressed. This article shows you how.
MORE INFORMATION
Step-by-Step ExampleThe following process sets two form level properties (dtKeyPress and dtMouseMove) to store the time of the last keystroke or mouse movement. The timer control verifies the elapsed time since the last occurrence of these two events. If more than the specified interval has elapsed, the form is released. 1. Create a new form. Add the following properties to the form:
2. In the Init method of the form, add the following code:
3. In the KeyPress method of the form, add the following code:
4. In the MouseMove method of the form, add the following code:
5. Add a timer control to the form. Set the Interval property of the timer
6. Add a text box to the form for testing purposes. Save and run the form.
7. The form should time out and release after the specified number of
Incorporating a Timeout into a FormsetTo adapt this example to close an entire formset, follow these steps: 1. Create the three properties specified in step 1 of the example so that 2. Place the Init code specified in step 2 in the Init method of the
3. Create the timer control on each individual form in the formset. This is
4. Change the reference of ThisForm in steps 3 and 4 of the example to
Additional query words: idle delay
|
Last Reviewed: April 20, 1997 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |