예제 #1
0
        private MessagePreviewResult NotifyListener(IKeyboardListener listener, Control target, Message msg)
        {
            MessagePreviewResult result = MessagePreviewResult.NotProcessed;
            Keys keyData;

            switch (msg.Msg)
            {
            case NativeMethods.WM_KEYDOWN:
            case NativeMethods.WM_SYSKEYDOWN:
                keyData = ((Keys)((int)((long)msg.WParam))) | Control.ModifierKeys;
                result  = listener.OnPreviewKeyDown(target, new KeyEventArgs(keyData));
                break;

            case NativeMethods.WM_CHAR:
            case NativeMethods.WM_SYSCHAR:
                KeyPressEventArgs e = new KeyPressEventArgs((char)((ushort)((long)msg.WParam)));
                result = listener.OnPreviewKeyPress(target, e);
                break;

            case NativeMethods.WM_KEYUP:
            case NativeMethods.WM_SYSKEYUP:
                keyData = ((Keys)((int)((long)msg.WParam))) | Control.ModifierKeys;
                result  = listener.OnPreviewKeyUp(target, new KeyEventArgs(keyData));
                break;
            }

            return(result);
        }
예제 #2
0
        private MessagePreviewResult NotifyListener(
            IKeyboardListener listener,
            Control target,
            Message msg)
        {
            MessagePreviewResult messagePreviewResult = MessagePreviewResult.NotProcessed;

            switch (msg.Msg)
            {
            case 256:
            case 260:
                Keys keyData1 = (Keys)(long)msg.WParam | Control.ModifierKeys;
                messagePreviewResult = listener.OnPreviewKeyDown(target, new KeyEventArgs(keyData1));
                break;

            case 257:
            case 261:
                Keys keyData2 = (Keys)(long)msg.WParam | Control.ModifierKeys;
                messagePreviewResult = listener.OnPreviewKeyUp(target, new KeyEventArgs(keyData2));
                break;

            case 258:
            case 262:
                KeyPressEventArgs e = new KeyPressEventArgs((char)(long)msg.WParam);
                messagePreviewResult = listener.OnPreviewKeyPress(target, e);
                break;
            }
            return(messagePreviewResult);
        }