Form. keyDown, KeyUp, and KeyPress cannot be used when you add shortcuts to a program, because some controls intercept key information. For example, if you put a Button on the Form and move the focus to it, press any key, Form. keyXXX is not triggered.
To solve this problem, the formal method is to override the Form. ProcessCmdKey method, which is called before the control processes the key information. However, this method is not applicable if it is more convenient and flexible to process shortcuts-for example, it is processed by another class. At this time, the best way is:
Add an additional menu to the form, design the Click Event processor for the menu item, set the ShortcutKeys attribute for it, and set the Visible of the menu to false.
Note that if you have more than one menu in one form, and the shortcut keys of different menu items are repeated, at this time, the event processor with at most one menu item will be called, specifically, the menu item is added to the DropDownItems of the parent menu item (whether the parent menu item is added to another parent control or not !) Search, the first Enable is a real menu item, and its event processor is called. This priority has nothing to do with whether the menu is visible or not, but is related to Enable.
Ps: When Microsoft Debug Symbols + Reflector is used for manual debugging, several lines of code are found. If a WinForms process attaches a debugger, in this program, press Ctrl + Break to use Debuger to freeze the program.
Pps: Is the source code of. Net Framework still unavailable? According to Scott, VS 2008 Express is set, and only Symbols is returned. The source code is still unavailable. If you want to switch to Microsoft's code, you will be prompted whether to display the Assembly :(