If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Delphi Component to control keypress event

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-10-04, 02:30
zulazriputra zulazriputra is offline
Registered User
 
Join Date: Feb 2004
Location: Malaysia
Posts: 8
Question Delphi Component to control keypress event

Hi,

I am searching for a DELPHI (version 3 to 7) component that can control the keypress event on a form. No matter where is the focus, we still can get the respond everytime we press the keyboard key.

Normally, this is how it goes. I have to put a procedure in a keypress event of every components that I've been used in the form. This is a big hassle.

So, in order to remove this hassle, I need the component that can behave like what I described in the first paragraph.
Just give me the name of the component.

I appreciate anybody that can help and thanks in advance.

Regards,
zulazriputra
Reply With Quote
  #2 (permalink)  
Old 03-12-04, 16:39
Qualm Qualm is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
What you want to do is quite easy.

From the Delphi help topic for "Keyboard event processing order":

Quote:
Keyboard events are received at several levels:

The application level, with an Application.OnMessage event.

You will rarely need to intercept keystrokes at the application level, but it is important to know that this first level is available.

The "shortcut-key" level

When you specify a shortcut key, such as those provided as a property of menu items, the keystroke is intercepted before the form sees it.

The form level

The form contains a KeyPreview property that enables you to code "global" keystroke events.

The component level

When you program key-press event handlers at the component level, the component with focus intercepts the keystroke.
So either handle Application.OnMessage, or put your code at the Form level.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On