开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜