LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I clear a PasswordCTRL

I created a text string variable and converted it to a password via the PasswordCtrl_ConvertFromString command.
The user enters a name into one text string and a password into the converted string.
When there is a login error, I send the user back to the same panel to try again.
Both strings contain the "incorrect' data entered previously and I wanted to clear that, so I used:

        SetCtrlVal (LoginPanelHandle, LoginPANEL_User_Name_STRING, "");
        SetCtrlVal (LoginPanelHandle, LoginPANEL_Password_STRING, "");

to clear the incorrect values from the GUI.  That worked; however, when this is done, the command

        PasswordCtrl_GetAttribute( LoginPanelHandle, LoginPANEL_Password_STRING,
                  ATTR_PASSWORD_VAL, &Password[0] );

does not function properly.  If you enter the incorrect password (for example "x" ) and then go back to the panel
to try again and enter something else (for example "y"), the PasswordCtrl_GetAttribute command actually returns
"xy" as the value.  I have also tried to strcpy "     " into Password.  That works, but once the Password is retrieved, it shows up as
"xy".  If you try again and enter "z" as the password, the PasswordCtrl_GetAttribute command returns the value of "xyz".

Note, if I do not use         SetCtrlVal (LoginPanelHandle, LoginPANEL_Password_STRING, "");
to clear out the GUI field, tho old password is there (in "****" form) and if the old one is backspaced and the
new one is entered, it works correctly.

What am I doing incorrectly?  What is a way to blank out the fields for a 2nd attempt?
Should I just ignore it and let the user delete the improper password?

0 Kudos
Message 1 of 3
(3,268 Views)

Hello,

instead of using  SetCtrlVal (LoginPanelHandle, LoginPANEL_User_Name_STRING, ""), use PasswordCtrl_SetAttribute(LoginPanelHandle, LoginPANEL_User_Name_STRING, ATTR_PASSWORD_VAL, "").

Message 2 of 3
(3,260 Views)
BINGO!!

Thanks.  This is my first experimentation with the password controls.
0 Kudos
Message 3 of 3
(3,256 Views)