G
Guest
I have a multi form (not MDI) application and I would like my program to
intercept keyboard input regardless witch form is active. I tried the usual
KeyUp event hander on the MainForm on the App first, but it didn’t do
anything because one of the controls of the form always seems to be selected.
Next, I tried to override the WndProc with the following code:
const int WM_KEYUP = 0x101;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_KEYUP:
{
Keys keys = (Keys)m.WParam.ToInt32();
if (keys == Keys.P)
DoSomething();
break;
}
}
base.WndProc(ref m);
}
But that doesn’t do anything. I can intercept the MouseMove event for
example but the KeyUp doesn’t seem to reach this function at all (I tried to
put a break point to the first statement after the case but it never got
there) . Does anyone know what to do?
intercept keyboard input regardless witch form is active. I tried the usual
KeyUp event hander on the MainForm on the App first, but it didn’t do
anything because one of the controls of the form always seems to be selected.
Next, I tried to override the WndProc with the following code:
const int WM_KEYUP = 0x101;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_KEYUP:
{
Keys keys = (Keys)m.WParam.ToInt32();
if (keys == Keys.P)
DoSomething();
break;
}
}
base.WndProc(ref m);
}
But that doesn’t do anything. I can intercept the MouseMove event for
example but the KeyUp doesn’t seem to reach this function at all (I tried to
put a break point to the first statement after the case but it never got
there) . Does anyone know what to do?