2009. október 10., szombat

How to implement delayed autotyping in a TDBEdit or TEdit


Problem/Question/Abstract:

Using a TDBEdit, I would like to achieve something like this on user input:
S ... (wait a few milliseconds) ... O ... (wait) ... M ... (wait) ... E

Answer:

procedure SendtextToControl(control: TWinControl; const S: string; interval: Integer {milliseconds});
var
  i: Integer;
begin
  for i := 1 to Length(S) do
  begin
    control.perform(WM_CHAR, Ord(S[i]), 0);
    control.Update;
    if i < Length(S) then
      Sleep(interval);
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése