INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Classes and Objects

Trap Cursor Movement in a Text Box on a Form. by EzLogic
Posted: 6 Nov 03

This worked for me in VFP,6, 7, 8

The problem:
When we use the text box in VFP on a form, it is a little clumsy.  What I mean is when you hit the backspace and you are at the beginning of the text box, the cursor leaves the text box and jumps to the previous box (according to your tab order), especially when the user hits the backspace and holds it to delete the entire content (It happens with me too).

Also, I hated it when I pressed the down/up key and the cursor jumps to different objects on the form.

So, this is what I DID:

-Create a new class based on TEXTBOX and name it what you wish (mine is TeknoBox)
-Open the Class Designer and modify it.
-Go to the class property
-Add Property "cNotify"
-Add Property "OkToLeave"

In the GotFocus() Event of the TextBox:
this.cnotify = SYS(2001,'NOTIFY')
SET NOTIFY OFF
This.oktoleave = .T.


In the KeyPress() Event:

LPARAMETERS jKeyCode, jShiftAltCtrl
IF jKeyCode = 127 OR jKeyCode = 4 OR jKeyCode = 19 OR;
   jKeyCode = 24 OR jKeyCode = 5 OR jKeyCode = 6 OR jKeyCode = 1
         this.Oktoleave = .f.
ELSE
        this.oktoleave = .t.
ENDIF


In the lostfocus() Event:

DO case
CASE this.cNotify = 'ON'
    SET NOTIFY ON
CASE THIS.CNOTIFY = 'OFF'
    SET NOTIFY OFF
ENDCASE


In the Valid() Event:

LOCAL lOkToleave
lOkToLeave = this.OkToLeave
this.OkToLeave = .t.
RETURN lOkToLeave




Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close