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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OOP ESCAPE handling on _SCREEN 1

Status
Not open for further replies.

tamayok

Programmer
Sep 4, 2001
99
PR
Hello!

I would like to assign a custom functionality to the ESCAPE key to apply only when there are no user-defined-forms/windows visible in the application. In other words, want to run a small procedure on _SCREEN.KeyPress.

I want to avoid using "ON KEY LABEL ESC" or "ON ESCAPE" commands; prefer to achieve this through OOP.

Can anyone help me with this?

Thanks!

Kenneth Tamayo
San Juan, Puerto Rico - USA


 
What version of VFP?
In version 8 or later you can use BINDEVENT()
Code:
oScrKey = CREATEOBJECT("MyKeyHandler")
BINDEVENT(_SCREEN,"KeyPress",oScrKey,"KeyHandler",1)

DEFINE CLASS MyKeyHandler AS CUSTOM
     PROCEDURE KeyHandler(nKeyCode, nShift)
   *** Your code here
     ENDPROC
ENDDEFINE

In previous versions:
(this is not tested)
Code:
oScrKey = CREATEOBJECT("MyKeyHandler")

DEFINE CLASS MyKeyHandler AS CUSTOM
    MyScreen = _SCREEN
     PROCEDURE MyScreen.KeyPress(nKeyCode, nShift)
   *** Your code here
     ENDPROC
ENDDEFINE




Borislav Borissov
 
Thanks Borislav,

YES! This is exactly what I needed, thanks...

I am using VFP 9.0, of course!

Kenneth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top