Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

Cascading OnKeyDown

I have a form embeded in the panel of another form and the embeded from has a ListView. I want to respond to the del key when the embedded ListView is the active control. KeyPreview is set to True for both forms.

In the host form's OnKeyDown I pass on the key to the embedded form OnKeyDown. This gets fired fine and in the embedded form OnKeyDown I check if the ActiveControl is the ListView but the ActiveControl is nil though the Listview is the active control.

How can I do this? Ideally I would have a OnKeyDown on the ListView but I don't know how to ensure that's fired.

Thanks and cheers, Tom.
0
boardtc
Asked:
boardtc
1 Solution
 
classmateCommented:
Probably the host form's activecontrol is the one you are expected to test. You can also test the Screen.activecontrol.

The Listview's onkeydown would normally be executed after the form's onkeydown, so if you don't change the value of Key or Shift during the form's onkeydown, the easiest should be to just implement the ListView's onkeydown as far as you don't need it to react when it's not focused.

classmate.
0
 
ILECommented:
weryy easy


just use


form1.keypreview:=true;


that will pass all key event automaticly

0
 
boardtcAuthor Commented:
Thanks classmate. Checking SCreen.ActiveControl did the trick.

I agree with you about the ListVuew.OnKeyDown being the place for it but as it never fires. Do you know how to ensure it's fired?

ILE, did you read my question? I appreciate you taking the time but that kind of response gives experts a bad name.

Cheers, Tom.
0
Industry Leaders: 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!

 
classmateCommented:
Unfortunately i have no experience with listviews.
I'd try it in a small test project with a single form.
If it does'nt fire here, it might rely on a property, or it might also be a bug or not supported at all. I'd also try to turn off the keypreview property, with the purpose of getting more familiar wiht the TListView control.
You can always debug the delphi source code of TListview, but i suspect most of its code is hidden by windows API.

regards
classmate.
0
 
boardtcAuthor Commented:
Unfortuntely classmate, this is still on my problem list, ListView.OnKeyDown doe not fire so my code never gets called. I don't know how to ensure it fires. Does anyone?
Cheers, Tom.
0
 
CleanupPingCommented:
tomcorcoran:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now