Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Virtual Keys in Form?

Status
Not open for further replies.

xkor8000

Programmer
Jun 10, 2015
3
I sent my Sample Project list_select.zip to show clearly what I made.

This contains 2 Executables ".exe":
-"test1.exe" is the Original Project
-"test2.exe" is the Same with the left ListBox disabled (which I don't want to disable it)

The "OnKeyDown" Event in "test2" worked fine, then in "test1" doesn't work.
I already tried "Form1.SetFocus;", but this does nothing for "OnKeyDown" Event.

Please can Someone know what is the Problem with "test1" Sample?

PS:
I use "Borland Delphi 7".
 
I'm not sure we'll want to download and run executables. If they are small projects then post the code along with the dfm files.
 
Well... sorry for the last Download Link. I sent an Attachment to make it easier (only the Source).

It's just a Test to show the common Problem which this happened often.
I want to tell what is the General Tip to know to use between the "OnKeyDown" in "Form1" with a ListBox enabled (only when disabled it, this strangely worked).

Must I use the Focus Function? Or another One?...
 
 http://files.engineering.com/getfile.aspx?folder=8fda02a5-bc5c-4af1-8fc1-3075288eb751&file=list_select(source).zip
You're using the Form's KeyDown event. You need to set the form's KeyPreview property to True (from Object inspector when the form is the "selected" component or via code say in the FormCreate event - "KeyPreview := True")
 
Thank you very much! Just did "KeyPreview" as True, then this works perfectly! [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top