Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tamar Granor
  Where is Tamar Granor?
 Elkins Park
 Pennsylvania - United States
 Tamar Granor
 To: marulam acong
  Where is marulam acong?
 bogor
 Indonesia
 marulam acong
 Tags
Subject: RE: Keyboard manipulation
Thread ID: 345228 Message ID: 345267 # Views: 81 # Ratings: 0
Version: Visual FoxPro 6 Category: Forms
Date: Monday, May 21, 2012 10:22:16 PM         
   


> Dear All,
>
> Currently i'm developing POS for client and i have problem when they ask me to manipulate the '0' in the keyboard. What they want is when the '0' key is pressed then it will shows '00' instead of '0'

Presumably, they only want this in certain situations (like after a decimal point). Create a subclass of textbox for those cases. In the subclass, use the KeyPress method to figure out when you're in the situation that class for adding the extra 0. Assuming it is for typing to the right of the decimal point, you might try something like this (which is untested):

LOCAL nPointPos, lHandled

lHandled = .F.
nPointPos = AT(".", This.Value)
IF m.nPointPos > 0 and This.SelStart > m.nPointPos
  * Cursor is to the right of the decimal point
  IF m.nKeyCode = ASC("0")
     This.Value = LEFT(This.Value, This.SelStart) + "00" + SUBSTR(This.Value, This.SelStart + 1)
     lHandled = .T.
     NODEFAULT
  ENDIF
ENDIF

IF NOT m.lHandled
   DODEFAULT(m.nKeyCode, m.nShiftAltCtrl)
ENDIF


Of course, if this is for typing to the right of the decimal point, you could just tell them not to worry about it, since leaving that blank will insert the necessary zeroes.

Tamar

ENTIRE THREAD

Keyboard manipulation Posted by marulam acong @ 5/21/2012 5:16:27 AM
RE: Keyboard manipulation Posted by onytoo @ 5/21/2012 12:52:16 PM
RE: Keyboard manipulation Posted by marulam acong @ 5/22/2012 11:51:05 AM
RE: Keyboard manipulation Posted by Jun Tangunan @ 5/24/2012 5:18:08 AM
RE: Keyboard manipulation Posted by David Mustakim @ 5/23/2012 8:17:08 PM
RE: Keyboard manipulation Posted by Cetin Basoz @ 5/21/2012 1:02:27 PM
RE: Keyboard manipulation Posted by Tamar Granor @ 5/21/2012 10:22:16 PM
RE: Keyboard manipulation Posted by marulam acong @ 5/22/2012 11:46:25 AM
RE: Keyboard manipulation Posted by Samir H. @ 5/22/2012 4:46:48 PM
RE: Keyboard manipulation Posted by marulam acong @ 5/22/2012 5:55:23 PM
RE: Keyboard manipulation Posted by onytoo @ 5/22/2012 6:32:53 PM
RE: Keyboard manipulation Posted by Muhammad Majid Ali Attari @ 5/24/2012 7:38:59 AM
RE: Keyboard manipulation Posted by David Mustakim @ 5/23/2012 8:22:44 PM
RE: Keyboard manipulation Posted by onytoo @ 5/24/2012 2:58:21 AM
RE: Keyboard manipulation Posted by marulam acong @ 5/22/2012 12:16:01 PM
RE: Keyboard manipulation Posted by David Mustakim @ 5/24/2012 7:20:34 AM
RE: Keyboard manipulation Posted by David Mustakim @ 5/30/2012 11:31:20 AM
RE: Keyboard manipulation Posted by onytoo @ 5/30/2012 3:57:13 PM