I have an application using the following code to get input based on a file generated from a third party application.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
switch (keyData)
{
case Keys.F1:
clicked_F1(null, null);
break;
case Keys.F2:
clicked_F2(null, null);
break;
case Keys.F3:
clicked_F3(null, null);
break;
}
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Form.TopMost is set to true and this.Activate() is called during the OnShown callback. This works on most machines but occasionally the keyboard input will not be passed to my application, windows help for example will pop up if F1 is pressed.
Can anyone explain this behavior? I need to ensure my form will receive these keyboard events.
Cheers, Richard