예제 #1
0
        private void txtHotkeyEditor_Enter(object sender, EventArgs e)
        {
            var dialog = new HotkeyEditorDialog();

            dialog.RegistredHotkey = RegistredHotkey;

            dialog.HotkeyProcessor = this;
            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                if (m_globalHotkeyAtom.HasValue)
                {
                    Win32A.UnregisterHotKey(this.Handle, m_globalHotkeyAtom.Value);

                    var win32Error = Marshal.GetLastWin32Error();
                    if (win32Error != Win32A.ERROR_SUCCESS)
                    {
                        var ex = new Win32Exception();
                        MessageBox.Show(this, ex.Message, "Cannot regitster hotkey", MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                }

                RegistredHotkey    = dialog.NewHotkey;
                m_globalHotkeyAtom = dialog.NewHotkeyAtom;
            }

            this.ActiveControl = null;
        }
예제 #2
0
        public void UnregisterHotkey(ushort?p_atom)
        {
            if (p_atom.HasValue)
            {
                var atom = p_atom.Value;

                Win32A.UnregisterHotKey(this.Handle, atom);
                Win32A.GlobalDeleteAtom(atom);
            }
        }