Exemplo n.º 1
0
        /// <summary>
        /// Registers a hot key in the system.
        /// </summary>
        /// <param name="modifier">The modifiers that are associated with the hot key.</param>
        /// <param name="key">The key itself that is associated with the hot key.</param>
        public void RegisterHotKey(ModifierKeys2 modifier, Keys key)
        {
            // increment the counter.
            _currentId = _currentId + 1;

            // register the hot key.
            if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
                throw new InvalidOperationException("Couldn’t register the hot key.");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Registers a hot key in the system.
        /// </summary>
        /// <param name="modifier">The modifiers that are associated with the hot key.</param>
        /// <param name="key">The key itself that is associated with the hot key.</param>
        public void RegisterHotKey(ModifierKeys2 modifier, Keys key)
        {
            // increment the counter.
            _currentId = _currentId + 1;

            // register the hot key.
            if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
            {
                MessageBox.Show("couldnt register hotkey!");
                throw new InvalidOperationException("Couldn’t register the hot key.");
            }
        }
Exemplo n.º 3
0
            /// <summary>
            /// Overridden to get the notifications.
            /// </summary>
            /// <param name="m"></param>
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);

                // check if we got a hot key pressed.
                if (m.Msg == WM_HOTKEY)
                {
                    // get the keys.
                    Keys          key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                    ModifierKeys2 modifier = (ModifierKeys2)((int)m.LParam & 0xFFFF);

                    // invoke the event to notify the parent.
                    if (KeyPressed != null)
                    {
                        KeyPressed(this, new KeyPressedEventArgs(modifier, key));
                    }
                }
            }
Exemplo n.º 4
0
 internal KeyPressedEventArgs(ModifierKeys2 modifier, Keys key)
 {
     _modifier = modifier;
     _key = key;
 }
Exemplo n.º 5
0
 internal KeyPressedEventArgs(ModifierKeys2 modifier, Keys key)
 {
     _modifier = modifier;
     _key      = key;
 }