Keypresses Like F1, F2 etc.

My application is MDI and each child window has a memo on it.

When you press keys, it appears in the memo as you would expect as the memo has focus. However, I still want the parent form to respond to things like the function keys and Ctrl-key combinations.

Is there a good, bad or easy way to do this?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tdk_manAuthor Commented:
OK, I've more or less solved this myself. What wasn't working before now seems to have started working now!

The only thing I don't seem to be able to detect is Ctrl combinations like Ctrl-G so I can pop up a panel for a Goto line number feature.

You can use Virtual Keys
make a search in delphi help about Virtual Keys & you'll find a good example.
if you didn't I'll send you an easy code.
tdk_manAuthor Commented:
I just came back to delete this question as I'd found what I was looking for. Virtual keys didn't really help a lot actually and I did it in the end by pinching info out of two separate code examples:

  If (key=71) and (shift = [ssCtrl])  Then
      // Ctrl-G  Goto Line Number

Thanks anyway!

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

tdk_manAuthor Commented:
Application for question to be deleted made with mods.

Suggestion made unfortunately did not solve the problem. (Virtual Keys can be used to detect the Control key but apparently not with another key such as Ctrl-G).
At risk of being ignored ;-) why don't you use the FormKeyDown (or component version of KeyDown) and send that to the parent form?

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

That captures virtually every keypress with the exceptions of PrtScr and one or two others.

Geoff M.
tdk_manAuthor Commented:

That's what my code (posted above) does...  :)

It uses both the shift and key values - rather than Virtual Keys.

You could use keyboard event.



If you want to do two keys:



TDK_Man - I've read through all your posts and I cannot find any which mention FormKeyDown...!

Geoff M.
tdk_manAuthor Commented:
Sorry - you misunderstood what I meant.

When I said "That's what my code (posted above) does", I was refering to the use of 'key' and 'shift' rather than Virtual Keys:

  If (key=71) and (shift = [ssCtrl])  Then
      // Ctrl-G  Goto Line Number

... which is in my memo's KeyDown section.

PAQed, with points refunded (300)

Friendly Neighbourhood Community Support Admin

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.