Board index » delphi » I have designed a calculator but need to intercept all keyboard keys

I have designed a calculator but need to intercept all keyboard keys

I have designed a calculator program with 10 keys for the numbers plus
the usual other key for the maths part i used to have a tlabel for the
sum but i thought of having a editbox to use instead so if i press any
of the buttons on the screen it alters the editbox text or if i enter
a number from the keyboard. how can i intercept all keyboard keys from
wherever in the form you have highlighted.

Thanks in Advance

Karl

 

Re:I have designed a calculator but need to intercept all keyboard keys


Quote
Shaggy wrote:

> I have designed a calculator program with 10 keys for the numbers plus
> the usual other key for the maths part i used to have a tlabel for the
> sum but i thought of having a editbox to use instead so if i press any
> of the buttons on the screen it alters the editbox text or if i enter
> a number from the keyboard. how can i intercept all keyboard keys from
> wherever in the form you have highlighted.

> Thanks in Advance

> Karl

Hi!

Try using the property KeyPreview := true (I think) from your main form.
It gets all keys from child controls. Just look for this property in the
online-help.

Ingo

Re:I have designed a calculator but need to intercept all keyboard keys


Shaggy wrote<8FjxN9IsvOhB5PGfeQqCV754=...@4ax.com>...

Quote
>I have designed a calculator program with 10 keys for the numbers plus
>the usual other key for the maths part i used to have a tlabel for the
>sum but i thought of having a editbox to use instead so if i press any
>of the buttons on the screen it alters the editbox text or if i enter
>a number from the keyboard. how can i intercept all keyboard keys from
>wherever in the form you have highlighted.

Use the form's OnShortCut event.

Re:I have designed a calculator but need to intercept all keyboard keys


hi Shaggy

Form1.KeyPreview := true;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
etc.

you'll need to set your edit box to read only.

hth

__
Ged

Other Threads