We need to handle this event in basic form, regardless of which controls currently have focus. We have a pair of global key teams that should work regardless of the focus of management.
This works by handling the PreviewKeyDown event on the form normally. When we add a user control to the form, the event no longer fires.
Did I miss something trivial here? Or do we need to handle the event in the user element first?
Thank you for your help!
Gratitude factor. When I get more time :) I will earn the "right"!
We have finished this:
, , :
ToolStripMenuItem.Visible = false
( ).
, . , whick
, , , , (, Page Up/Page Down), .
, P/Invoke, - Form.KeyPreview true. , , , . OnKeyDown, OnKeyPress / OnKeyUp .
Form.KeyPreview
PreviewKeyDown , . , . P/Invoke. SetWindowsHookEx pinvoke.net - . MS KB #, , , .
, , , , .
InitializeComponent(); - :
foreach (Control control in this.Controls) { control.PreviewKeyDown += new PreviewKeyDownEventHandler(HandlePreviewKeyDown); }
I THINK I have to do the trick. In your HandlePreviewKeyDown method, you can do your job, and it should run regardless of which control has focus.