Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need *'s to show in password field
Message
De
15/09/2000 04:31:57
 
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00416579
Message ID:
00416774
Vues:
35
Gerry,

Here's some quick and dirty code you could try.
PARAMETERS m.length
PRIVATE m.length, pass_str, key, cur_curs

PUSH KEY CLEAR

IF parameters() = 0           	&&  if no parameters passed
	m.length = 6                &&  use password length of 6
ENDIF

pass_str = ''
key = 0

cur_curs = set('cursor') = 'ON'   &&  current cursor state
SET CURSOR on
cur_win = woutput()

DEFINE WINDOW pass_win ;
	AT  0.000, 0.000  ;
	SIZE 7.0,40.000 ;
	TITLE " Password " ;
	FONT "Arial", 8 ;
	STYLE "B" ;
	NOFLOAT ;
	NOCLOSE ;
	SHADOW ;
	NOMINIMIZE ;
	DOUBLE ;
	COLOR RGB(,,,192,192,192)
MOVE WINDOW pass_win CENTER

ACTIVATE WINDOW pass_win

@ 05,15 SAY ''

DO WHILE key # 13             &&  accept until car_return
	SET COLOR OF NORMAL TO x
	m.key = inkey(0)

	DO CASE

	CASE isalpha(chr(m.key)) OR (m.key >= 32 AND m.key <= 64)
		pass_str = pass_str + chr(m.key)

	CASE m.key = 19 OR m.key = 127 OR m.key = 7
		@ row(),col()-1 SAY ' '
		@ row(),col()-1 SAY ''
		pass_str = substr(pass_str,1,len(pass_str)-1)

	ENDCASE

	IF len(pass_str) >= m.length
		m.key = 13
	ENDIF

	SET COLOR OF NORMAL TO 
	@ 05,15 SAY space(m.length)
	@ 05,15 SAY replicate('*',len(pass_str))
ENDDO

RELEASE WINDOW pass_win

IF empty(cur_win)
	ACTIVATE SCREEN
ENDIF

IF .not. cur_curs             &&  if cursor was off
	SET CURSOR OFF              &&  set it back on
ENDIF

POP KEY

RETURN(pass_str)
Jens Erik


>Is there a routine handy which will show asterisks ('*') in password fields, instead of the text the user enters?
>
>I've gotten spoiled by VFP! I'm modifying a Foxpro/DOS app.
>
>- Gerry
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform