The Keyboard.ppt

The Keyboard.ppt

The Keyboard Jim Fawcett CSE778 – Advanced Windows Programming derived from a presentation by Yi-Yang Huang Jayashree Venkatesh Ignoring the keyboard Microsoft windows and windows forms class handle many keyboard functions themselves. Ignore keystrokes in menu selection. Windows forms programs define keyboard accelerators to invoke common menu items. Dialog boxes also have a keyboard interface, but programs need not monitor the keyboard when a dialog box is active. Who’s got the focus? A particular keystroke has only a single destination, which is of type Control or a descendant of Control, such as Form. The object that has input focus receives a keystroke event. A form has input focus when it is the active form. Active form is usually the topmost form on the desktop. Active form is available from the only static property implemented by Form. Type : Form Property : ActiveForm Accessibility : get A form can attempt to activate itself by calling void Activate(). When a form changes to or from the Activated state it gets these events: Event Method Delegate Argument Activated OnActivated EventHandler EventArgs Deactivate OnDeactivate EventHandler EventArgs Keyboards and Characters Keyboard is: A collection of distinct physical keys A means of generating character codes (Unicode). Four groups of keys Toggle keys (Caps, Num, Scroll locks, Insert) Shift keys (Shift, Ctrl, Alt) Noncharacter keys (function, pause, del) Character keys (letter,no,Tab,Backspace,Enter,Esc) Keys Down and Keys Up Keystroke event handlers in your form class: Event Method Delegate Argument KeyDown OnKeyDown KeyEventHandler KeyEventArgs KeyUp OnKeyUp KeyEventHandler KeyEventArgs Event Overrides protected override void OnKeyDown(KeyEventArgs kea) { … } protected override void OnKeyUp (KeyEventArgs kea) { …} Void MyKeyDownHandler (object objSender, KeyEventsArg

文档评论(0)

1亿VIP精品文档

相关文档