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

How to use PgUp/PgDn as Previous/Next command 2

Status
Not open for further replies.

rob444

Programmer
Nov 5, 2002
633
NL
How do you get the pgup/pgdn keys on the keyboard to function as cmdprev/cmdnext in a form, without using the keypressed method?

I want to offer more keyboard control when scrolling a table with a form.

Thanks.
Rob.

 
Rob,

Are you using a grid? Page up/down work there natively.

What situation are you working with?


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Rob,

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)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Stewart and Mike,

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.

Rob.
 
Rob,

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.
 
Stewart,

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.

Rob.
 
Rob,

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.
 
Stewart,

The textboxes aren't read only.

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.

Rob.
 
Rob,

When using the KeyPreView method and the KeyPress method I'm unable to edit the fields on the form.

Why? Trapping PgDn and PgUp shouldn't interfere with normal editing. What code did you try in your Keypress? What setting have you got for Keypreview?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Rob,

I can see nothing in the KeyPress event code that will cause the effect you describe.

Did you try commenting it out and then editing the fields? What about setting KeyPreview to .F. and leaving the code in and then seeing what happens.


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike and Stewart,

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!

Thanks guys, a star for both of you!!!

Rob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top