|
-
December 1st, 2004, 05:54 AM
#1
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
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
December 1st, 2004, 07:42 AM
#2
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....
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|