Define shortcut keys in Delphi without registering hotkeys (simple and ingenious, but the current form is active)

Source: Internet
Author: User

First step: Change the property "KeyPreview" to true in the form where you want to implement the shortcut key;
The second step: in the form to implement the shortcut key in the onkeypress event to fill in a process name (in Object inspector), fill in and enter into the event code to fill in the section;
Step three: Fill in the event handling process, here is an example:
Procedure tfrmmain.keypress (Sender:tobject; var key:char);
Begin
If key in ["] Then
Begin
B_play_pause.click;
End
End

The above example realizes "in an active form, pressing the SPACEBAR is equivalent to clicking the Play/Pause button", which is also a shortcut for many of the current players. Inside the brackets can be filled with multiple characters, in the middle with a comma separated by the English half-width, to monitor the function of multiple shortcut keys, in addition, the brackets also support the sub-boundary type, for example: [' 0 ' ... ' 9 ', ' a ' ... ' z '] This enables input monitoring of the digital 0~9, lowercase English letters a~z The If post-processing process can perform a case key of operation on key, for example:
Case Key of
0:to do something one;
1:to do something;
When the keyboard input 0 o'clock executes the to-do something one statement, when the keyboard input 1 o'clock executes the to-do something, the equivalent of the switch statement in the C language.

http://blog.csdn.net/chaijunkun/article/details/4125624

Define shortcut keys in Delphi without registering hotkeys (simple and ingenious, but the current form is active)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.