Esempio n. 1
0
        private const int WM_DESTROY = 0x2;   //窗口消息:销毁

        protected override void WndProc(ref Message msg)
        {
            base.WndProc(ref msg);
            switch (msg.Msg)
            {
            case WM_HOTKEY:     //窗口消息:热键
                int tmpWParam = msg.WParam.ToInt32();
                if (tmpWParam == HotKeyID)
                {
                    do_work();
                }
                break;

            case WM_CREATE:     //窗口消息:创建
                SystemHotKey.RegHotKey(this.Handle, HotKeyID, SystemHotKey.KeyModifiers.Ctrl, Keys.L);
                break;

            case WM_DESTROY:                                     //窗口消息:销毁
                SystemHotKey.UnRegHotKey(this.Handle, HotKeyID); //销毁热键
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case DefaultMessageValue.WmHotKey:
                switch (m.WParam.ToInt32())
                {
                case 100:
                    buttonCaptureImage_Click(null, null);
                    break;
                }
                break;

            case DefaultMessageValue.WmCreate:
                SystemHotKey.RegHotKey(Handle, 100, KeyModifiers.Ctrl | KeyModifiers.Alt, Keys.Z);
                break;

            case DefaultMessageValue.WmDestory:
                SystemHotKey.UnRegHotKey(Handle, 100);
                break;

            case DefaultMessageValue.WmSyscommand:
                if (m.WParam.ToInt32() == DefaultMessageValue.ScMinimize)
                {
                    WindowState   = FormWindowState.Minimized;
                    ShowInTaskbar = true;
                }
                break;

            case DefaultMessageValue.WmRbuttondown:
                //int i = 43;
                break;
            }
            base.WndProc(ref m);
        }
Esempio n. 3
0
 protected override void OnClosed(EventArgs e)
 {
     if (NotiCenterWindowViewModel.IsHotKeyEnabled)
     {
         SystemHotKey.UnRegHotKey(_thisWindowHandle, c_hotKeyId);
     }
     base.OnClosed(e);
 }
Esempio n. 4
0
 protected override void OnClosed(EventArgs e)
 {
     if (AppUtil.IsHotKeyEnabled)
     {
         SystemHotKey.UnRegHotKey(_thisWindowHandle, c_hotKeyId);
     }
     base.OnClosed(e);
 }
Esempio n. 5
0
 protected override void OnClosed(EventArgs e)
 {
     if (AppUtil.IsHotKeyEnabled)
     {
         SystemHotKey.UnRegHotKey(_thisWindowHandle, c_hotKeyId);
     }
     hwndSource?.Dispose();
     hwndSource = null;
     base.OnClosed(e);
     Application.Current.Shutdown();
 }
Esempio n. 6
0
 protected override void OnClosed(EventArgs e)
 {
     if (ClientAppType.IsMinerClient)
     {
         if (AppUtil.IsHotKeyEnabled)
         {
             SystemHotKey.UnRegHotKey(_thisWindowHandle, c_hotKeyId);
         }
         hwndSource?.Dispose();
         hwndSource = null;
     }
     base.OnClosed(e);
 }
Esempio n. 7
0
        //重载系统方法,用于处理热键
        protected override void WndProc(ref Message msg)
        {
            base.WndProc(ref msg);
            switch (msg.Msg)
            {
            case WM_HOTKEY:     //窗口消息:热键
                int tmpWParam = msg.WParam.ToInt32();
                //MessageBox.Show("hot key:" + tmpWParam);
                //ctrl+NumPad0开启自动跟踪
                //ctrl+enter关闭自动跟踪
                if (usbDevice != null && systemStatus != null)
                {
                    if (tmpWParam == HotKeyID1)
                    {
                        usbDevice.IfAutoTrace(true);
                        systemStatus.autoTrace = usbDevice.autoTrace;
                        this.textBox_msg.Text  = systemStatus.GetSytemStatus();
                        ShowToolTip("已开启自动跟踪");
                    }
                    else if (tmpWParam == HotKeyID2)
                    {
                        usbDevice.IfAutoTrace(false);
                        systemStatus.autoTrace = usbDevice.autoTrace;
                        this.textBox_msg.Text  = systemStatus.GetSytemStatus();
                        ShowToolTip("已关闭自动跟踪");
                    }
                    else if (tmpWParam == HotKeyID3)
                    {
                        ShowToolTip("测试热键");
                    }
                }
                break;

            case WM_CREATE:     //窗口消息:创建
                SystemHotKey.RegHotKey(this.Handle, HotKeyID1, SystemHotKey.KeyModifiers.Ctrl, Keys.NumPad0);
                SystemHotKey.RegHotKey(this.Handle, HotKeyID2, SystemHotKey.KeyModifiers.WindowsKey, Keys.NumPad0);
                SystemHotKey.RegHotKey(this.Handle, HotKeyID3, SystemHotKey.KeyModifiers.Alt, Keys.Add);
                break;

            case WM_DESTROY:                                      //窗口消息:销毁
                SystemHotKey.UnRegHotKey(this.Handle, HotKeyID1); //销毁热键
                SystemHotKey.UnRegHotKey(this.Handle, HotKeyID2); //销毁热键
                SystemHotKey.UnRegHotKey(this.Handle, HotKeyID3); //销毁热键
                break;

            default:
                break;
            }
        }
Esempio n. 8
0
 protected override void OnClosed(EventArgs e)
 {
     SystemHotKey.UnRegHotKey(_thisWindowHandle, c_hotKeyId);
     base.OnClosed(e);
 }