Why is my OnKeyDown event handler not processed?

I am using Delphi 2009 and I followed the tutorial at delphi.about.com , but I could not install it.

I created an OnKeyPress / OnkeyDown event and set a breakpoint to find out if this event was fired, but it wasn’t fired in any way.

Where is the problem?

EDIT

procedure TFormMain.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Beep; //breakpoint is set here.
end;
+3
source share
1 answer

You can try to install

Form1.KeyPreview := True;

Perhaps the event is not correctly transmitted before the form.

EDIT: after viewing the link, I think you probably did it, as it is mentioned in the article. Maybe you forgot this line?

+22
source

Source: https://habr.com/ru/post/1715423/


All Articles