VuurSnikkel
Programmer
Hi there ppl...
I'm having trouble getting my application to always react on a FormKeyDown-event. Let's say I've got some form and it contains an OK- and a Cancel-button. I want the form to perform the OKClick-function when I press Enter and the CancelClick-function when I press Escape. The logical way to do it (as far as I know) would be the following:
Procedure TSomeForm.FormKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
Begin
Case Key Of
VK_ESCAPE: CancelButtonClick(Self);
VK_RETURN: OKButtonClick(Self);
End;
End;
The problem is that when the form contains some random elements (buttons, text boxes etc.) the form will not respond to the FormKeyDown but the keyhandler of the component that currently has focus will kick in.
I COULD put a KeyDown-event on each of the components with the above code to catch Enter- and Escape-presses, but that's probably not the way to go.
So is there some way in which I can automatically bypass the keyhandler for the components and give primacy to the form's keyhandler? Help would be greatly appreciated.
GRTZ and thanx in advance,
VuurSnikkel.
I'm having trouble getting my application to always react on a FormKeyDown-event. Let's say I've got some form and it contains an OK- and a Cancel-button. I want the form to perform the OKClick-function when I press Enter and the CancelClick-function when I press Escape. The logical way to do it (as far as I know) would be the following:
Procedure TSomeForm.FormKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
Begin
Case Key Of
VK_ESCAPE: CancelButtonClick(Self);
VK_RETURN: OKButtonClick(Self);
End;
End;
The problem is that when the form contains some random elements (buttons, text boxes etc.) the form will not respond to the FormKeyDown but the keyhandler of the component that currently has focus will kick in.
I COULD put a KeyDown-event on each of the components with the above code to catch Enter- and Escape-presses, but that's probably not the way to go.
So is there some way in which I can automatically bypass the keyhandler for the components and give primacy to the form's keyhandler? Help would be greatly appreciated.
GRTZ and thanx in advance,
VuurSnikkel.