NitroBlaze
asked on
Hotkey component for form onkeydown event?
Is it possible for a hotkey component to be used to configure the key combinations pressed in a form's onkeydown event?
I would like to create two forms where the first form has the hotkey event that configures the hotkey combination. When the second window is displayed, a hidden component is visible when the user presses the combination keys on the form that's configured in the first form.
I would appreciate source code implemented in the answers, thanks.
I would like to create two forms where the first form has the hotkey event that configures the hotkey combination. When the second window is displayed, a hidden component is visible when the user presses the combination keys on the form that's configured in the first form.
I would appreciate source code implemented in the answers, thanks.
ASKER
is it possible to use the pre-installed Hotkey component located in the Advanced components tab in Delphi? It handles different properties like Modifiers for the Shift and Shortcut for the Key property.
Delphi 6 right? I don't have it at home.
Regards Jacco
Regards Jacco
ASKER
Yes. In that case, what components do you recommend me to check out on this matter? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The code does not accept common windows keyboard shortcuts like (Ctrl-A : Select All), that's workable by registering the combination beforehand, other than that, it works perfectly.
Thanks.
Thanks.
Try setting KeyPreview of the form to True
If you do that the form will see the key first. If you set Key to 0 in FormKeyDown the active control of the form will not handle the key. (It is tricky sometimes though).
And don't forget the HotKey component has a property for not allowing some key combinations.
Regards Jacco
If you do that the form will see the key first. If you set Key to 0 in FormKeyDown the active control of the form will not handle the key. (It is tricky sometimes though).
And don't forget the HotKey component has a property for not allowing some key combinations.
Regards Jacco
I am not sure I understand completely what you mean.
Just let me know if this is it.
Is it something like this:
class TForm1(TForm)
procedure FormCreate(Sender: TObject);
HotKeyController: THotKeyController; (* your component *)
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HotKeyController.Key := VK_ENTER;
HotKeyController.Shift := [ssCtrl, ssAlt];
end;
class TForm2(TForm)
Form2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
end;
procedure Form2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Form1.HotKeyController.Tes
begin
MyHiddenControl.Visible := True;
end;
end;
Regards Jacco