User control and Keyboard Shortcuts
Hey there!
I have a user custom control, which has a tool bar and a context menu. I have assigned the shortcuts to the menu items... and really they should work without any problem...
now when you put this user control in another application, the shortcuts dont work...
what's the dilemma here?
same thing happens with List View, which has a context menu, with shortcuts specified for menuitems. but the application does nothing when the shortcuts are applied...
can someone show me the way out?
Thanks,
andy
Re: User control and Keyboard Shortcuts
I implemented the IMessageFilter interface in the main form. and added an override for PreFilterMessage.
some thing like this...
Code:
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
public bool PreFilterMessage(ref Message m)
{
Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
if(m.Msg == WM_KEYDOWN)
{
if(keyCode == Keys.F5)
{
MyUserControl.PreFilterMessage(ref m);
return true;
}
}
return false;
}
Similarly, prefiltermessage is implemented in the user control...
hope someone will find this information usefull....