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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Key Preview event on a Form!!!!

Status
Not open for further replies.

Kckronic21

Programmer
Jul 29, 2001
81
US
Hi, Could someone explain to me what key preview means on a Form and what purpose does it serve? Thanks!
 
You can use the KeyPreview property to specify whether the form-level keyboard event procedures are invoked before a control's keyboard event procedures (KeyDown, KeyUp, and KeyPress).

You can set the KeyPreview property by using the form's property sheet, a macro, or Visual Basic.

You can set the KeyPreview property in any view.

You can use the KeyPreview property to create a keyboard-handling procedure for a form. For example, when an application uses function keys, setting the KeyPreview property to True allows you to process keystrokes at the form level rather than writing code for each control that might receive keystroke events.

To handle keyboard events only at the form level and prevent controls from receiving keyboard events, set the KeyAscii argument to 0 in the form's KeyPress event procedure, and set the KeyCode argument to 0 in the form's KeyDown and KeyUp event procedures.

If a form has no visible or enabled controls, it automatically receives all keyboard events.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top