Textbox Password Property ...

Moderator: Rathinagiri

Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México
Has thanked: 1 time
Been thanked: 2 times

Re: Textbox Password Property ...

Post by Javier Tovar »

Hola PeteGW,

No trabaja.

Saludos

User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines
Been thanked: 2 times

Post by dhaine_adp »

Hi Chang,

In addition to the contribs/samples posted above, here's another trick. This is the code snippet.

Code: Select all

************************************
METHOD UserLogin() CLASS UserManager

   LOCAL lRetVal := FALSE
   LOCAL acUser_ := ARRAY(3)
   
   PRIVATE nTries := 1
   PRIVATE lActivated := .f.
   PRIVATE lSwitchOff := .f.
   PRIVATE lUserName  := .f.

   DEFINE WINDOW frmLogin;
      AT 0,0;
      WIDTH 465 HEIGHT 212;
      TITLE "Login";
      ICON "MAINICON";
      MODAL NOSYSMENU ;
      FONT "Arial" SIZE 9 ON INIT ::Open() ON RELEASE ::Close()
         
      @  52,210 LABEL lblUserName OF frmLogin VALUE "User Name"; 
         ACTION Nil WIDTH  70 HEIGHT 20 FONT "Arial" SIZE 9
         
      @  87,210 LABEL lblPassword OF frmLogin VALUE "Password"; 
         ACTION Nil WIDTH  70 HEIGHT 20 FONT "Arial" SIZE 9
         
      @  48,290 TEXTBOX txbUserName OF frmLogin HEIGHT 24 VALUE "" WIDTH  120;
         FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 10 ON LOSTFOCUS Nil;
         ON ENTER ( frmLogin.txbPwd.Setfocus, frmLogin.txbPwd.CaretPos := 0 );
         ON CHANGE ::tbxChangeArg( This.Name )
         
      @  84,290 TEXTBOX txbPassword OF frmLogin HEIGHT 24 WIDTH  120;
         PASSWORD MAXLENGTH 10 UPPERCASE ON LOSTFOCUS Nil ON ENTER lRetVal := ::LoginButtonOK(@acUser_)
         
      @  84,290 TEXTBOX txbPwd OF frmLogin HEIGHT 24 VALUE "" WIDTH  120;
         MAXLENGTH 10 ON CHANGE ::tbxChangeArg( This.Name )
         
      @  10, 10 IMAGE imgLogo OF frmLogin PICTURE ::cImageFile WIDTH  150 HEIGHT 160 STRETCH
      @  10,130 IMAGE imgLock OF frmLogin PICTURE ::cImageHome + "key.bmp" WIDTH  30 HEIGHT 30 STRETCH
         
      @  10,170 LABEL Label_3 OF frmLogin VALUE "Please enter your security credentials..."; 
         ACTION Nil WIDTH  280 HEIGHT 20 FONT "Arial" SIZE 11 BOLD FONTCOLOR BLUE
         
      @  30,170 FRAME Frame_1 OF frmLogin CAPTION NIL; 
         WIDTH  280 HEIGHT 100 FONT "Arial" SIZE 9 BACKCOLOR Nil FONTCOLOR Nil OPAQUE
         
      @ 140,280 BUTTON btnOk OF frmLogin CAPTION "&Ok" ACTION lRetVal := ::LoginButtonOk(@acUser_) WIDTH 80 HEIGHT 24 FONT "Arial" SIZE 9
         
      @ 140,370 BUTTON btnCancel OF frmLogin CAPTION "&Cancel" ACTION lRetVal := ::LoginButtonCancel() WIDTH 80 HEIGHT 24 FONT "Arial" SIZE 9
         
   END WINDOW
   frmLogin.Center
   frmLogin.txbUserName.Value := "User ID"
   frmLogin.txbUserName.FontColor := GRAY
   frmLogin.txbPassword.Hide
   frmLogin.txbPwd.Value     := "Password"
   frmLogin.txbPwd.FontColor := GRAY
   frmLogin.txbPwd.CaretPos  := 0
   frmLogin.txbUserName.Setfocus()
   frmLogin.txbUserName.CaretPos := 0
   lActivated := .t.
   frmLogin.Activate
   IF lRetVal
      ::aUserInfo_ := acUser_
   ENDIF
   
   IF nTries > LOGINTHRESHOLD
      ::AccessDenied := TRUE
   ENDIF
   
   RETURN lRetVal


 *****************************************************
METHOD tbxChangeArg( cControlName ) CLASS UserManager

   IF .NOT. lActivated
      RETURN NIL
   ENDIF
   
   DO CASE
      CASE cControlName == "txbUserName"
         IF .NOT. lUserName
            frmLogin.txbUserName.Value := SUBSTR( ALLTRIM( frmLogin.txbUserName.Value ), 1, 1 )
            frmLogin.txbUserName.FontColor := BLACK
            frmLogin.txbUserName.CaretPos := 1
            lUserName := .t.
         ENDIF
      CASE cControlName == "txbPwd"
         IF .NOT. lSwitchOff
            frmLogin.txbPwd.Hide()
            frmLogin.txbPassword.Show()
            frmLogin.txbPassword.Value := SUBSTR( ALLTRIM( frmLogin.txbPwd.Value ),1 ,1 )
            frmLogin.txbPassword.Setfocus()
            frmLogin.txbPassword.CaretPos := 1
            lSwitchOff := .t.
         ENDIF
   ENDCASE
   RETURN NIL
What it does?
The initial form display is shown on the .png attached file. Once the user began typing the TEXTBOX control txbPwd will become hidden and its initial or first character typed on it will be forwarded to txbPassword. At this point txbPassword will be shown and the keyboard buffer will be automatically put those remaining character typed by the user without any extra coding. It all happened in a fraction of a second.

The reason why you need some tricks is because once PASSWORD is defined with TEXTBOX control it is simply not readable and you can't changed it at runtime (as already mentioned in the posting above).
Attachments
This is the initial display
This is the initial display
pass.PNG (52.12 KiB) Viewed 2356 times
This when the users typed on it
This when the users typed on it
pass1.PNG (54.06 KiB) Viewed 2357 times
Regards,

Danny
Manila, Philippines

franco
Posts: 465
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 18 times

Post by franco »

Hello all,
A different question on passwords.
I seen a program where if there was no program action for a certain time, say 30 seconds, the password window would open and employee had to enter new password to continue with program.
Must be easy, at start of program create timer variable???, any thoughts.
Franco
All The Best,
Franco
Canada

User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines
Been thanked: 2 times

Post by dhaine_adp »

Hello all,
A different question on passwords.
I seen a program where if there was no program action for a certain time, say 30 seconds, the password window would open and employee had to enter new password to continue with program.
Must be easy, at start of program create timer variable???, any thoughts.
Franco
Hi Franco,

That would be a nice idea however the windows screen saver and power plan settings can take over if set properly through group policy, local policy and user settings or through the Domain Controller (if there is one). A proper IT GI (General Instruction/General Information) for all network users can also contain a written policy that somehow instructs them that if they would leave their workstations for more than a minute they should press Windows Logo + L to instantly lock their workstations. Having set those rules any breached can then be subject for investigation, suspension or termination. For other platforms or OS the same rules can be applied too.

RFIDS's, proximity card readers, smartcard readers and biometric systems have the same sleep mode functionality. For me, I've always look for those built-in security features before I implemented my own and as much as possible try to take advantage of it. I think its a matter of preference if you will but you are absolutely right, that can also be another layer of security.
Regards,

Danny
Manila, Philippines

Post Reply