Solved

Keypresses Like F1, F2 etc.

Posted on 2003-11-18
11
574 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 72
delphi exception 7 63
Delphi...Split view - idea? 1 42
DBGrid or StringGrid ? 6 71
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now