Click to See Complete Forum and Search --> : User control and Keyboard Shortcuts


Andy Tacker
December 1st, 2004, 04:54 AM
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

Andy Tacker
December 1st, 2004, 06:42 AM
I implemented the IMessageFilter interface in the main form. and added an override for PreFilterMessage.
some thing like this...
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....