User: alciro    User
 Original    Translate to:  Deutsch  English  Français  中文  
 

Programación en C++ Builder

 Arrays (arrays)
 Pointers
3. Example of class in c + +
8. AnsiString class methods
 C + + projects
 Packages, distribute an application without installation
 Exchange or bubble sorting
 String string.h functions

11.2. Derivatives TWinControl

OnKeyDown

Occurs when the user presses a key and the control has focus. This event meets all the keys, any alphanumeric key, including function keys in combination with Shift and Alt keys control (Ctrl) and the mouse buttons pressed.

 typedef void __fastcall (__closure * TKeyEvent) (System:: TObject * Sender, Word & Key, Classes:: TShiftState Shift);
__property TKeyEvent OnKeyDown = {read = FOnKeyDown, write = FOnKeyDown}; 

The Shift delivers variable parameter indicates that the control key (Shift, Alt, Ctrl) is combined with the pressed key (Key value.)

State Meaning
ssShift The Shift key is held down.
ssAlt The Alt key is held down.
ssCtrl The Ctrl key is held down.

The Following code aborts a print job if the user presses Esc Note That You Should September KeyPreview to True to Ensure That the OnKeyDown event handler of Form1 is street.

 void __fastcall TForm1:: FormKeyDown (TObject * Sender, WORD & Key, TShiftState Shift)

{
if (Key == VK_ESCAPE & & Printer () -> Printing)
{
Printer () -> Abort ();
MessageDlg ("Printing aborted", mtInformation, TMsgDlgButtons () <<Mboko, 0);
}
} 

OnKeyPress

It happens when you press an alphanumeric key or keys Tab, Backspace, Enter and Esc

 typedef void __fastcall (__closure * TKeyPressEvent) (System:: TObject * Sender, char & Key);
__property TKeyPressEvent OnKeyPress = {read = FOnKeyPress, write = FOnKeyPress}; 

This event handler displays a message dialog box WAS Specifying Which key pressed:

 void __fastcall TForm1:: FormKeyPress (TObject * Sender, char & Key)

{
keyString char [25];
KeyString [0] = Key;
strcpy (& keyString [1], "Was Pressed");
Application-> MessageBox (keyString, "Key Press", MB_OK);
} 

OnKeyUp

Release occurs when any key is pressed. This event meets all the keys, any alphanumeric key, including function keys in combination with Shift and Alt keys control (Ctrl) and the mouse buttons pressed.

 typedef void __fastcall (__closure * TKeyEvent) (System:: TObject * Sender, Word & Key, Classes:: TShiftState Shift);
__property TKeyEvent OnKeyUp = {read = FOnKeyUp, write = FOnKeyUp}; 

The Shift delivers variable parameter indicates that the control key (Shift, Alt, Ctrl) is combined with the pressed key (Key value.)

State Meaning
ssShift The Shift key is held down.
ssAlt The Alt key is held down.
ssCtrl The Ctrl key is held down.

Loading
copyright © 2007-2024  www.alciro.org  All rights reserved.         
Share |