Einzelnen Beitrag anzeigen

Der schöne Günther

Registriert seit: 6. Mär 2013
6.159 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Function keys onFormKeyDown

  Alt 11. Sep 2013, 12:58
I've never tried it myself, but this fine gentleman on SO reports that

Zitat:
The KeyPreview property of the current active form is checked for the KeyUp-, KeyDown- and KeyPress- event handlers of the current active control. I.e.: a key press in any control results in the check of the form's KeyPreview property.

If that property is True, the event handler in question invokes the event handler of the form prior to that of itself. If the form's event handler does not change the key value to 0 (or #0, depending on KeyPress or KeyDown/KeyUp), then the active control's event handler takes back over, otherwise the event is considered handled.
So it's pretty much like gestures work in Delphi: The Event in your form fires first, no matter which component is currently selected. If you assign Key := 0 in your TForm1.FormKeyDown , then the component that is currently selected won't even notice a key way pressed. If you want it do to some additional stuff, then don't zero it out

So KeyPreview itself does not affect other handlers, while setting Key to zero does.
  Mit Zitat antworten Zitat