Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual FoxPro
Expertise: Beginner
Nov 5, 1999

Backspaces and Form Focus

Question:
I have two questions:
  1. When using the Backspace key to delete content in a text box, the control is passed to the preceding text box once all data is erased. Can this be disabled?
  2. When calling one form from another, the form to be loaded doesn't receive the focus; thus the user has to click on the form first before using the form. How do I correct this?

Answer:
To prevent loss of focus when pressing Backspace once all data has been erased, put the following code into the KeyPress Event of the textbox:

 
LPARAMETERS nKeyCode, nShiftAltCtrl

*-- If textbox value is empty and the 
*-- backspace key was pressed, ignore
*-- the key
IF EMPTY(this.Value) AND nKeyCode = 127
   NODEFAULT
ENDIF
Regarding the focus issue, you may want to call the SetFocus() method of the called form to make sure that it receives focus.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date