Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Keypresses Like F1, F2 etc.

Posted on 2003-11-18
11
Medium Priority
?
584 Views
Last Modified: 2011-09-20
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?

TDK_Man
0
Comment
Question by:tdk_man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 1

Author Comment

by:tdk_man
ID: 9775163
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.

TDK_Man
0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9775166
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.
0
 
LVL 1

Author Comment

by:tdk_man
ID: 9775385
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
    Begin
      // Ctrl-G  Goto Line Number
    End;

Thanks anyway!

TDK_Man
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:tdk_man
ID: 9775571
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).
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9777275
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);
begin
  Form2.FormKeyDown(Sender, Key, Shift);
end;

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

Geoff M.
0
 
LVL 1

Author Comment

by:tdk_man
ID: 9782999
gmayo

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

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

TDK_Man
0
 
LVL 5

Expert Comment

by:Hypoviax
ID: 9783834
You could use keyboard event.

Example:

keybd_event(vk_return,0,0,0)

If you want to do two keys:

keybd_event(vk_control,0,0,0);
keybd_event(vk_escape,0,0,0);

Regards,
Hypoviax

0
 
LVL 8

Expert Comment

by:gmayo
ID: 9785832
TDK_Man - I've read through all your posts and I cannot find any which mention FormKeyDown...!

Geoff M.
0
 
LVL 1

Author Comment

by:tdk_man
ID: 9789709
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
    Begin
      // Ctrl-G  Goto Line Number
    End;

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

TDK_Man
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 9803142
PAQed, with points refunded (300)

Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question