c# Shortcut中没有shift+方向键,咋样把它加进入啊

解决方案 »

  1.   

    [DllImport("user32.dll", SetLastError = true)]
    public static extern bool RegisterHotKey(
                IntPtr hWnd,
                int id,
                KeyModifiers fsModifiers,
                Keys vk
                ); 
    [DllImport("user32.dll", SetLastError = true)]
    public static extern bool UnregisterHotKey(
                IntPtr hWnd,
                int id
                );
    自己定义
    然后protected override void WndProc(ref Message m)
    {
                const int WM_HOTKEY = 0x0312;
                switch (m.Msg)
                {
                    case WM_HOTKEY:
                        switch (m.WParam.ToInt32())
                        {
                            case ***//这里填需要处理的值,如果有其他的还可以继续添加
                                    break;
                        }
                        }
                        break;
                }
                base.WndProc(ref m);
    }
      

  2.   

    那我咋知道m.Msg值是多少啊?比如shift+Left
      

  3.   


    public MainForm()
    {
    ...
    RegisterHotKey(Handle, 100, 4, Keys.Left); // Shift +光标左箭头
    RegisterHotKey(Handle, 200, 4, Keys.Right); / /Shift +光标右箭头
    RegisterHotKey(Handle, 300, 4, Keys.Up); // Shift +光标上箭头
    RegisterHotKey(Handle, 400, 4, Keys.Down); // Shift +光标下箭头
    }public enum KeyModifiers
    {
    None = 0,
    Alt = 1,
    Control = 2,
    Shift = 4,
    Windows = 8
    }
      

  4.   

    RegisterHotKey这个就是让你自己定义的