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

Form.Keypress does not catch F2 key

Status
Not open for further replies.

DirkVFP

Programmer
Aug 25, 2005
57
NL
In the Keypress method on a form I created all keys are catched, except the F2-key (yes, I set KeyPreview = .T.). Trying to trap the F2 key with an ON KEY LABEL works but I find that a bad solution, I want to work the OOP way.

So my keyboard isn't broken and I haven't done and SET commands. What am I missing out here?
 
Couldn't find an Edit button, but this line
So my keyboard isn't broken and I haven't done and SET commands. What am I missing out here?
should be:

So my keyboard isn't broken and I haven't done any SET commands. What am I missing out here?
 
I just tested this with a simple form containing a single textbox and it worked fine, so there must be something in your code somewhere that's trapping the F2.

Tamar
 
I also created a new project, put only a form in there with no controls. Turned KeyPreview on and put this code in the KeyPress event of the form:
Code:
WAIT (STR(nKeyCode)) WINDOW
And again, all keys are caught except the F2 key...

Tried this code also on another computer and again, the F2 isn't caught there! The keyboards of the both computers aren't broken so it's my VFP. I'm using VFP 7.00.0000.9262 on both computers, it seems my problem lies here.
 
Don't have VFP 7 loaded here but just tried a blank form with Dirk's KeyPress in VFP 6 & 8. VFP 6 displays -1 when F2 is pressed. VFP 8 just ignores the keystroke. Looks like the behaviour changed with VFP 7. What version are you on Tamar?

BTW, both versions ignore F1.



Geoff Franklin
 
Ijust tried:
Code:
WAIT (STR(nKeyCode)) WINDOW
In the KeyPress of the form with VFP 8.

Default, F2 was ignored, but when I changed ShowWindow=2 As Top Level it F2 returned -1.

Regards,

Mike
 
First of all, I tested with DEBUGOUT rather than WAIT WINDOW because it's a cleaner test.

I tested in VFP 9 SP1 beta. Just tested in VFP 8 SP1 and no problem there either. Now tested VFP 7; works there for me, too.

Can everyone please retest with this code in the form's KeyPress:

LPARAMETERS nKeyCode, nShiftAltCtrl

DEBUGOUT nKeyCode, nShiftAltCtrl

Tamar
 
Hi Tamar,

Yup, VFP8 SP1 DEBUGOUT works. I wonder why ShowWindow default didn't show it.

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top