Re: Keypress Event problem



On 24 Feb, 01:41, "Paul E. Schoen" <pst...@xxxxxxxxx> wrote:
I have added an OnKeypress routine to my main form. It seems to work OK if
I press the key and wait for the subsequent process to complete, but it
causes an access error if I press the key twice or more in rapid
succession. The procedure performs some transmissions of data on the serial
port,
<snip>


Why not "lift" the OnKeyPress handler while it is handling an
event ...

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
Self.OnKeyPress := nil; // stop further keypresses triggering the
event
//
// your event handling code
//
Self.OnKeyPress := Self.FormKeyPress; // restore keypress events
end;

Alan Lloyd

.