procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
Found: boolean;
i,SelSt: Integer;
TmpStr: string;
begin
if Key in ['a'..'z'] then Dec(Key,32);
with (Sender as TEdit) do
begin
SelSt := SelStart;
if (Key = Chr(vk_Back)) and (SelLength <> 0) then
TmpStr := Copy(Text,1,SelStart)+Copy(Text,SelLength+SelStart+1,255)
else if Key = Chr(vk_Back) then {SelLength = 0}
TmpStr := Copy(Text,1,SelStart-1)+Copy(Text,SelStart+1,255)
else {Key in ['A'..'Z', etc]}
TmpStr := Copy(Text,1,SelStart)+Key+Copy(Text,SelLength+SelStart+1,255);
if TmpStr = '' then Exit;
{ update SelSt to the current insertion point }
if (Key = Chr(vk_Back)) and (SelSt > 0) then Dec(SelSt)
else if Key <> Chr(vk_Back) then Inc(SelSt);
Key := #0; { indicate that key was handled }
if SelSt = 0 then
begin
Text:= '';
Exit;
end;
end;
实际上就是Delphi中的帮助。