Tedit判断输入是手动按键还是扫描设备

这里指的输入设置主要是扫描枪或者磁条卡刷卡设备

如果仅是IC卡ID卡的,直接设置ReadOnly为True就可以了

根据输入速度判断

OnKeyPress

……………..

if NeedCard and _IsKey then

begin

//

if Edit1.Text = '' then

begin

lctime := GetTickCount;

Timer_input.Enabled := True;

WriteLog('开始');

end

else if (GetTickCount - lctime) > 50 then

//超过50ms 认为是手动输入

begin

Edit1.Text := '';

Key := Chr(0);

WriteLog('手动');

end

else

begin

lctime := GetTickCount;

end;

end;

屏蔽Ctrl+V直接粘贴

OnKeyDown

……………..

if (ssCtrl in Shift) and (Key = Ord('V')) then

begin

if Clipboard.HasFormat(CF_TEXT) then

Clipboard.Clear;

Key := 0;

end;

屏蔽系统右键

OnContextPopUp

begin

Handled:=True;

End;

定时器检测,字符长度,小于2个清空输入框

原文地址:https://www.cnblogs.com/jspdelphi/p/9494086.html