ComponentFactory.Krypton.Docking.PI.IsKeyDown C# (CSharp) Method

IsKeyDown() public static method

Is the specified key currently pressed down.
public static IsKeyDown ( Keys key ) : bool
key Keys Key to test.
return bool
        public static bool IsKeyDown(Keys key)
        {
            return KEY_DOWN == (GetKeyState(key) & KEY_DOWN);
        }

Usage Example

Beispiel #1
0
        public bool PreFilterMessage(ref Message m)
        {
            switch (m.Msg)
            {
            case PI.WM_MOUSELEAVE:
                // Only interested in the mouse leave if it relates to the floating window and so ignore any
                // message that comes from the mouse leaving the source of a drag such as a docked window or
                // a workspace/navigator tab.
                if (m.HWnd == FloatingWindow.Handle)
                {
                    // If mouse has left then we need to finish with docking. Most likely reason is the focus
                    // has been shifted to another application with ALT+TAB.
                    DragEnd(Control.MousePosition);
                    Dispose();
                }
                break;

            case PI.WM_KEYDOWN:
            {
                // Extract the keys being pressed
                Keys keys = ((Keys)((int)m.WParam.ToInt64()));

                // Pressing escape ends dragging
                if (keys == Keys.Escape)
                {
                    DragQuit();
                    Dispose();
                }

                return(true);
            }

            case PI.WM_SYSKEYDOWN:
            {
                // Extract the keys being pressed
                Keys keys = ((Keys)((int)m.WParam.ToInt64()));

                // Pressing ALT+TAB ends dragging because user is moving to another app
                if (PI.IsKeyDown(Keys.Tab) && ((Control.ModifierKeys & Keys.Alt) == Keys.Alt))
                {
                    DragQuit();
                    Dispose();
                }

                break;
            }

            case PI.WM_MOUSEMOVE:
                if (_monitorMouse)
                {
                    // Update feedback to reflect the current mouse position
                    DragMove(Control.MousePosition);
                }
                break;

            case PI.WM_LBUTTONUP:
                if (_monitorMouse)
                {
                    DragEnd(Control.MousePosition);
                    Dispose();
                }
                break;
            }

            return(false);
        }