Solved

Keypresses Like F1, F2 etc.

Posted on 2003-11-18
11
583 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

631 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