Código: Selecionar todos
FUNCTION GetSecret( cSenha, nRow, nCol, nLen )
LOCAL cText, nKey, cSetColor
DEFAULT nLen To 20
cSetColor := SetColor("7/0,/0")
@ nRow, nCol SAY Replicate( " ", nLen ) //COLOR SetColorFocus()
@ nRow, nCol SAY Replicate( "*", Len(Alltrim(cSenha)) ) //COLOR SetColorFocus()
cText := cSenha
DO WHILE .T.
@ nRow, nCol + Len( cText ) SAY ""
nKey := Inkey( 600, INKEY_ALL - INKEY_MOVE + 1024) //HB_INKEY_GTEVENT )
DO CASE
CASE nKey == 0
QUIT // KEYBOARD Chr( K_ESC ) + "S"
CASE nKey == K_RBUTTONDOWN
KEYBOARD Chr( K_ESC )
CASE nKey < 1 .OR. nKey > 126
LOOP
CASE nKey == K_ENTER
cText := Pad( cText, 20 )
EXIT
CASE nKey = K_ESC
EXIT
CASE nKey == K_BS .OR. nKey == K_LEFT
IF Len( cText ) > 0
cText := Substr( cText, 1, Len( cText ) - 1 )
@ nRow, nCol SAY Replicate( " ", nLen )
@ nRow, nCol SAY Replicate( "*", Len(Alltrim(cText)) )
ENDIF
CASE Len( cText ) == nLen
OTHERWISE
cText += Upper( Chr( nKey ) )
@ nRow, nCol SAY Replicate( "*", Len(Alltrim(cText)) )
ENDCASE
ENDDO
SetColor( cSetColor )
RETURN cText

