Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the Escape Key... 1

Status
Not open for further replies.

BlindPete

Programmer
Jul 5, 2000
711
US
Lets say I have several forms in sceen. I want to use the escape key to close what ever form has focus. Any suggestions?
 
There are many ways to do this.
1. Define 'ON KEY ESCAPE' function (SET ESCAPE should be OFF for this). For example,
ON KEY ESCAPE _screen.Activeform.Release
2. When all of these forms have 'close' buttons, assign .T. to 'Cancel' property of button. When users press ESC for such form, 'Cancel' button Click event will be fired.
3. Define base class for all these forms, assign .T. to 'KeyPreview' property and write code in KeyPress event to close form when ESC key (code 27) pressed.

Any of above ways may cause 'unwritten changes in control' problem - when user typed something, than press ESC - in some cases VFP do not apply value property of control to the bound control source. So, get active control and simple command 'm.loActiveControl.Value = m.loActiveControl.Value' fixes this.

 
Excellent. Thanks. Just what I was looking for.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top