Handling release key in custom panel control
I have custom control derived from Panel and I need to handle selecting with mouse. I found that for panel I must override ProcessCmdKey 开发者_如何学Cand it is working for pressing keys but what if I want to handle when control key is release? Thanks
Perhaps this can help you:
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
protected override bool ProcessKeyPreview(ref Message m)
{
if (m.Msg == WM_KEYDOWN && (Keys)m.WParam == Keys.ControlKey)
{
//Do something
}
else if (m.Msg == WM_KEYUP && (Keys)m.WParam == Keys.ControlKey)
{
//Do something
}
return base.ProcessKeyPreview(ref m);
}
And you could take a look at this (If you haven't already): http://support.microsoft.com/kb/320584
精彩评论