LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Password Control - allow paste and prevent copy or cut

In this thread and this thread there is discussion about the shortcomings of the Password Control in the Toolbox with respect to cut/copy/paste behavior.
 
In short, the control key sequences for cut copy and paste to not get handled properly because they do not generate an EVENT_KEYPRESS (and therefore actually bypass the section of code commented with "/* disallow cut & paste, etc.. */" ). 
 
Those threads sought workarounds to continue to disallow all those operations, but I'm looking to modify the behavior to permit pasting, but prevent copy or cut.  That really is the way it should be, given the challenge of typing in decent passwords (notwithstanding the issues related to receiving a password in plain text!).
 
I started trying to make the changes but it was not as straightforward as I had hoped.
 
Has anyone done this already, and willing to share it?
 
Thanks,
Ian
 
 
 
 
0 Kudos
Message 1 of 3
(3,988 Views)

As a simpler step, I'm trying to settle on rejecting paste operations, rather than misleadingly allowing paste to put text into the control.

I have added this to the panel callback in pwctrl.c

case EVENT_VAL_CHANGED:
    {
    short keyinfo;
    keyinfo = GetKeyState(VK_CONTROL);  //If the high-order bit is 1, the key is down
    if( keyinfo & 0x8000) {
     pwInfo->password[0] = 0;        /* delete whole password */
     SetCtrlAttribute(panel, control, ATTR_CTRL_VAL, "");
     Beep();
    }
    }

If this is good, it might be a worthwhile addition to pwctrl.c that ships with CVI .. but I'd like some others to review & test it.

--Ian

Message 2 of 3
(3,967 Views)

I was watching for a way to disable the ctrl+v functionality because I`m asking a user to write down a password and confirm the new password by writing it again in a new string. This option helped me to disable simple copy-paste the first entered string.

0 Kudos
Message 3 of 3
(2,282 Views)