What is the function of the KeyPreview property of a form? (set shortcut keys and hooks)

Source: Internet
Author: User
If you set the KeyPreview property of the form to true, the form will take precedence over the control of the keyboard event to get the activation right. For example, if the form Form1 and its text box Text1 are ready to respond to the KeyPress event, the following code will first activate the KeyPress event of the form:

Private Sub Form_Load ()
Me.keypreview = True
End Sub

Private Sub form_keypress (KeyAscii as Integer)
MsgBox "This is the KeyPress event of the form"
End Sub

Private Sub text1_keypress (KeyAscii as Integer)
MsgBox "This is the KeyPress event of the text box"
End Sub

What is the function of the KeyPreview property of a form? (set shortcut keys and hooks)

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.