Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ON KEY LABEL command problem
Message
From
15/07/2014 00:16:07
 
 
To
14/07/2014 23:49:44
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01603678
Message ID:
01603680
Views:
65
>Hi,
>I want user to press the HOME key to set focus to the first edit box control in the form.
>
>The following code not work.
>
>
>ON KEY LABEL HOME thisform.txtCusno.SetFocus()
>
You don't say what the error is (if any). I suspect ThisForm is not available in the context of ON KEY LABEL. The help for that command says "Note that ON KEY LABEL operates outside of the scope of a form; the KeyPress event can be used within forms to execute code when a key is pressed."

KeyPress/KeyPreview are the preferred way to do this sort of thing. In your case you would:

- set the Form's .KeyPreview property to .T.

- in the Form's .KeyPress( ) method have code like this:
LPARAMETERS nKeyCode, nShiftAltCtrl

IF nKeyCode = 1
	NODEFAULT
	
	This.txtcusno.SetFocus( )

ENDIF
Further information at http://fox.wikis.com/wc.dll?Wiki~KeyPress~WIN_COM_API .
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform