Do you mean that that you have Next and Previous navigation buttons on the form, and you want to link these to the PdDn and PgUp keys respectively? If so, then they Keypress event is the easiest way to do it.
Do you have any special reason for wanting to avoid Keypress?
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
No, I don't have a grid.
Just a form that contains most of a record and that through that form the record is editable.
Mike, I want to avoid Keypress because with Keypress the form acts strange when editing a field, the form shows the old contents of the field when leaving the fields focus with enter or arrow-up/down.
I can't think of anything else other than the form KeyPreview method.
An alternative to using Page up/down is to give the command buttons a hot-key which the user can access with the Alt key.
In case you don't know how to create a hot key - in the caption of the button you need to put the characters \< in front of the letter you want to make hot. So if your button said Next you would make the caption property read \<Next. That would make the n the hot key.
Hope that helps,
Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
When using the KeyPreView method and the KeyPress method I'm unable to edit the fields on the form.
And that is what puzzles me...
Thanks for the suggestion of using hotkeys.
The problem is that I ported an old foxpro 2.6 dos app to vfp9 and in that old app the users were used to browse through the records of a table with pageup/down, and frankly I personally like that too.
Remains the question how to do that and in the same time retain the possibility to edit / enter fields on the form.
If you try to edit the fields, do you get a WINDOW saying that the control is read-only? If not, what exactly happens when you try typing into one of the fields. I assume that the fields appear on the form as textboxes?
I don't think the KeyPreview property+KeyPress event would prevent editing of other controls in itself.
What happens if you comment-out all the code (except the LPARAMETERS nKeyCode, nShiftAltCtrl line) in the form KeyPress event?
Can you post the code in your KeyPress method?
Hope that helps,
Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
The results are strange, in the textbox with focus I can only enter 1 character and that character is the first characters of all characters in the textbox.
Here is the keypress event code:
LPARAMETERS nKeyCode, nShiftAltCtrl
DO CASE nKeyCode
CASE nKeyCode = 18
thisform.cmdvorige.click()
CASE nKeyCode = 3
thisform.cmdvolgende.click()
CASE nKeyCode = 27
thisform.cmdmenu.click()
ENDCASE
THISFORM.Refresh
*********************
cmdvorige is the cmdprev command, cmdvolgende is the cmdnext command and cmdmenu releases the form.
I posted the keypress event code above.
I noticed that I had a thisform.refresh in the keypress event that is already in the commandbutton code so I removed that.
After recompiling TWICE it works fine now!!!
After recompiling the first time it didn't.
I'm experiencing some strange VFP9 behaviour I think.
But what the heck, its working now!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.