Cascading OnKeyDown

Posted on 2003-03-05
Medium Priority
Last Modified: 2010-04-04
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.
Question by:tomcorcoran
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

Accepted Solution

classmate earned 375 total points
ID: 8074552
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.


Expert Comment

ID: 8076501
weryy easy

just use


that will pass all key event automaticly


Author Comment

ID: 8082310
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.

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


Expert Comment

ID: 8102071
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.


Author Comment

ID: 8787924
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.

Expert Comment

ID: 9316916
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 
Post your closing recommendations!  No comment means you don't care.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

800 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