Beispiel #1
0
        private void registerHotKey(Keys key, HotKeyModifiers modifiers)
        {
            string atomName = string.Empty;
            IntPtr atomId;

            atomName = key.ToString() + modifiers.ToString() + Environment.TickCount.ToString();
            if (atomName.Length > 255)
            {
                atomName = atomName.Substring(0, 255);
            }

            atomId = GlobalAddAtom(atomName);
            if (atomId == IntPtr.Zero)
            {
                throw new Exception("Impossible d'enregistrer l'atome du raccourci !");
            }

            if (!RegisterHotKey(this.Handle, atomId.ToInt32(), (int)modifiers, (int)key))
            {
                GlobalDeleteAtom(atomId);
                //throw new Exception("Impossible d'enregistrer le raccourci !");
            }

            this.hotkeys.Add(new HotKeyData(key, modifiers, atomId));
        }
Beispiel #2
0
        /// <summary>
        /// Registers the hot keys.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="modifiers">The modifiers.</param>
        private void RegisterHotKeys(Keys key, HotKeyModifiers modifiers)
        {
            var    atomName = string.Empty;
            IntPtr atomId;

            atomName = key.ToString() + modifiers.ToString() + Environment.TickCount.ToString();
            atomName = atomName.Substring(0, Math.Min(atomName.Length, 255));

            atomId = GlobalAddAtom(atomName);
            if (atomId == IntPtr.Zero)
            {
                throw new Exception("Unable to save shortcut atom !");
            }

            if (!RegisterHotKey(this.owner.Handle, atomId.ToInt32(), (int)modifiers, (int)key))
            {
                GlobalDeleteAtom(atomId);
                throw new Exception("Unable to save shortcut !");
            }

            this.registerHotKeys.Add(new HotKeysData(key, modifiers, atomId));
        }
Beispiel #3
0
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String"/> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(Modifiers.ToString() + "+" + Key.ToString());
 }
Beispiel #4
0
        private void registerHotKey(Keys key, HotKeyModifiers modifiers)
        {
            if (m.FATAL)
                return;

            string atomName = String.Empty;
            IntPtr atomId;
            atomName = key.ToString() + modifiers.ToString() + Environment.TickCount.ToString();

            if (atomName.Length > 255)
                atomName = atomName.Substring(0, 255);

            atomId = GlobalAddAtom(atomName);
            if (atomId == IntPtr.Zero)
                m.FatalAlert("L'atomId est invalide !", "Erreur", ToolTipIcon.Error);
            else
            {
                if (!RegisterHotKey(this.Handle, atomId.ToInt32(), (int)modifiers, (int)key))
                {
                    GlobalDeleteAtom(atomId);
                    m.FatalAlert("Impossible d'enregistrer le raccourci <" + key.ToString() + "+" + modifiers.ToString().Replace("Control", "Ctrl") + "> car celui-ci est déjà utilisé par une autre application..", "Erreur", ToolTipIcon.Error);
                }
                else
                    hotkeys.Add(new HotKeyData(key, modifiers, atomId));
            }
        }
Beispiel #5
0
        private void registerHotKey(Keys key, HotKeyModifiers modifiers)
        {
            string atomName = string.Empty;
            IntPtr atomId;
            atomName = key.ToString() + modifiers.ToString() + Environment.TickCount.ToString();
            if (atomName.Length > 255) {
                atomName = atomName.Substring(0,255);
            }

            atomId = GlobalAddAtom(atomName);
            if (atomId == IntPtr.Zero) {
                throw new Exception("Impossible d'enregistrer l'atome du raccourci !");
            }

            if (!RegisterHotKey(this.Handle, atomId.ToInt32(), (int)modifiers, (int)key)) {
                GlobalDeleteAtom(atomId);
                throw new Exception("Impossible d'enregistrer le raccourci !");
            }

            this.hotkeys.Add(new HotKeyData(key, modifiers, atomId));
        }