Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
KeyPress Event
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00080369
Message ID:
00080633
Views:
24
>I've been trying to find a sample if a form's .KeyPress event in action without success.
>
>What I'm trying to do is allow my base form class top process next previous etc by using the keyboard as well as using the toolbar. I've got it working well, except that the key values seem to be duplicated with other key's values. There must be a way. My code in the KeyPress event is...
>
>do case
>	case nKeyCode = 19 	&& Ctrl S
>		oToolbar.tbSearch.Click
>	case nKeyCode = 2	&& Ctrl Right
>		oToolBar.tbNext.Click
>	case nKeyCode = 26	&& Ctrl Left
>		oToolBar.tbPrev.Click
>	case nKeyCode = 29	&& Ctrl Home
>		oToolBar.tbFirst.Click
>	case nKeyCode = 23	&& Ctrl End
>		oToolBar.tbLast.Click
>endcase
>
>
>Three questions.
>
>1.How do I determine that the Ctrl key is pressed so I don't process other keys (eg; 19 is Ctrl-s and Alt-r)
>
>2. How do I determine the difference between Ctrl-Right and Ctrl-b, both of which return a keycode of 2.
>
>3. How do I ensure that the keys I want to use are removed from the buffer and don't get passed to the control - and those that I don't want to use are passed to the control.
>
>The help and manuals are no help on this. There seems to also be no reference to this in UT's extensive knowledge base - ie; I'm dumb and can't see something everyone else takes as obvious :)
>
>Steve

Well, You're better to see the help of KeyPress!!!
Highlight The Word 'KeyPress' and Press 'F1' to get the help!!
Or in event Window, select KeyPress Row and Press 'F1' !!

There is two parameters on KeyPress,
LPARAMETERS nKeyCode, nShiftAltCtrl

nKeyCode is the Code you use, nShiftCtrl is the Shift, Ctrl, Alt State!!
where Shift = 1, Ctrl = 2, Alt = 4!!
* For Check Ctrl + Alt are pressed, nShiftCtrl will be 6 (i.e. 2+4)

To avoid Default action on Control!
Just add a code.

NoDefault

For example,
Your Situation
do case
	case nKeyCode = 19 and nShiftCtrl = 2	&& Ctrl S
		oToolbar.tbSearch.Click
	case nKeyCode = 2 and nShiftCtrl = 2	&& Ctrl Right
		oToolBar.tbNext.Click
	case nKeyCode = 26 and nShiftCtrl = 2	&& Ctrl Left
		oToolBar.tbPrev.Click
	case nKeyCode = 29 and nShiftCtrl = 2	&& Ctrl Home
		oToolBar.tbFirst.Click
	case nKeyCode = 23 and nShiftCtrl = 2	&& Ctrl End
		oToolBar.tbLast.Click
endcase
But You need to see Help first!!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform