(If I remove the second GET WHEN clause it will move to it but doesn't change to the gotfocus colours)
TIA
Peter
- Code: Select all Expand view
#include "FWCE.ch"
#include "vkey.ch"
STATIC oWnd,oFont[3]
STATIC oGetPass
***********************
FUNCTION Main()
DEFINE FONT oFont[1] NAME "Ariel" SIZE 4, 12 BOLD
DEFINE FONT oFont[2] NAME "Ariel" SIZE 12, 14 BOLD
DEFINE FONT oFont[3] NAME "Ariel" SIZE 16, 20 BOLD
DEFINE WINDOW oWnd
@ 4.75,5 BUTTON oExit PROMPT "Exit" OF owND SIZE 60, 30 FONT oFont[1] ACTION {|| oWnd:END()}
ACTIVATE WINDOW oWnd ON INIT UserLogin()
******************
FUNCTION UserLogin()
LOCAL oExit
LOCAL oDlg
LOCAL nEmploy := 0
PRIVATE lValidUser := lValidPass := .f.
PRIVATE nTries := 0
PRIVATE oGetEmploy
PRIVATE cNewpass := SPACE(10)
DEFINE DIALOG oDlg OF oWnd TITLE "Login" FROM 3, 3 TO 16, 27.5
@ .25,4 Say "Employee" COLOR CLR_RED,CLR_WHITE SIZE 60,8 // FONT oFont[2]
@ 1.25,.5 GET oGetEmploy VAR nEmploy PICT "999999999999999" OF oDlg SIZE 90,16 UPDATE ; //FONT oFont[2]
VALID {|| lValidUser := ValidUser(nEmploy,oDlg)}
oGetEmploy:bGotFocus := { || oGetEmploy:SetColor(CLR_RED,CLR_GRAY)}
oGetEmploy:bLostFocus := { || oGetEmploy:SetColor(CLR_HBLUE,CLR_WHITE)}
@ 3.1,4 Say "Password" COLOR CLR_RED,CLR_WHITE SIZE 60,8 //FONT oFont[2]
@ 4.5,.5 GET oGetPass VAR cNewPass PICT "XXXXXXXXXX" OF oDlg SIZE 90,16 WHEN lValidUser ; // FONT oFont[2]
VALID { || lvalidPass := ValidPass(cNewPass,oDlg) } UPDATE
oGetPass:bGotFocus := { || oGetPass:SetColor(CLR_RED,CLR_GRAY)}
oGetPass:bLostFocus := { || oGetPass:SetColor(CLR_HBLUE,CLR_WHITE)}
@ 4.75,5 BUTTON oExit PROMPT "Exit" OF oDlg SIZE 30, 10 ACTION {|| oWnd:END()} // FONT oFont[2]
ACTIVATE DIALOG oDlg VALID lValidPass
******************************
FUNCTION ValidUser(nUser,oDlg)
IF GetAsyncKey( VK_LBUTTON ) .OR. GetAsyncKey( VK_LBUTTON )
oWnd:End()
ENDIF
DO case
case nUser = 1
RETURN .f.
case nUser = 2
//(oGetPass:SetFocus(),.t.)
// oGetPass:Refresh()
//oGetPass:bLostFocus := { || oGetPass:SetColor(CLR_HBLUE,CLR_WHITE),SetFocus()}
oGetpass:SetFocus()
RETURN .t.
ENDCASE
RETURN .F.
*******************************
FUNCTION ValidPass(cNewPass,oDlg)
IF GetAsyncKey( VK_LBUTTON ) .OR. GetAsyncKey( VK_LBUTTON )
oWnd:End()
ENDIF
IF EMPTY(TRIM(cNewPass))
RETURN .F.
ENDIF
cDecrypt := "secret"
IF cDecrypt = TRIM(cNewpass)
lValidpass := .t.
oDlg:End()
ELSE
nTries++
IF nTries >= 3
oWnd:END()
ENDIF
cNewpass := SPACE(10)
odlg:update()
RETURN .F.
ENDIF
RETURN .t.