INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to use Virtual Keys in Form?

How to use Virtual Keys in Form?

(OP)
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".

RE: How to use Virtual Keys in Form?

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.

RE: How to use Virtual Keys in Form?

(OP)
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?...

RE: How to use Virtual Keys in Form?

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")

RE: How to use Virtual Keys in Form?

(OP)
Thank you very much! Just did "KeyPreview" as True, then this works perfectly! thumbsup2

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close