![]() Example |
![]() ![]() ![]() |
acAppEvents component.
|
type
|
TacAppKeyEvent = procedure(Sender: TObject; var Key: Word; Shift: TShiftState; KeyName: String; RepeatedKeypress: Boolean) of object;
|
|
property OnAppKeyDown: TacAppKeyEvent;
|
The OnAppKeyDown event occurs when user presses any key in ANY window or control within the application. Use the OnAppKeyDown event to process any keypresses in whole program, even if the focus aimed to the control with different handle, in any form within current application process thread.
|
|
For example, you would like to minimize your program when user press an "Esc" key. Then just insert following code to the OnAppKeyDown procedure handle:
|
procedure TForm1.acAppEvents1AppKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState; KeyName: String; RepeatedKeypress: Boolean);
|
begin
|
if not RepeatedKeypress and (Key = VK_ESCAPE) then
|
Application.Minimize;
|
end;
|
|
![]() |
Key | Virtual key code for pressed key (use VK_xx contants, for example, VK_ESCAPE = 27, VK_F1 = 112 and so forth);
|
ShiftState | The state of control keys like Shift, Ctrl and Alt;
|
KeyName | The name of pressed key;
|
RepeatedKeypress | Is the the key is down before the evvent occurs is sent. This is keypress is repeated if True.
|
OnAppKeyUp event.
|