Ejemplo n.º 1
0
        public void RegisterHotkey()
        {
            if (HotKeyWindow == null)
            {
                HotKeyWindow = new HotKeyNativeWindow(this);
            }

            try
            {
                if (Key != Keys.None)
                {
                    HotKeyWindow.RegisterHotkey();
                }
                else
                {
                    if (HotKeyWindow.Handle != IntPtr.Zero)
                    {
                        HotKeyWindow.DestroyHandle();
                    }
                    HotKeyWindow = null;
                }
            }
            catch
            {
                if (HotKeyWindow.Handle != IntPtr.Zero)
                {
                    HotKeyWindow.DestroyHandle();
                }
                HotKeyWindow = null;
                throw;
            }

            IsRegistered = true;
        }
Ejemplo n.º 2
0
        public bool RegisterHotkey()
        {
            if (HotKeyWindow == null)
            {
                HotKeyWindow = new HotKeyNativeWindow(this);
            }

            try
            {
                if (Key != Keys.None)
                {
                    HotKeyWindow.RegisterHotkey();
                }
                else
                {
                    if (HotKeyWindow.Handle != IntPtr.Zero)
                    {
                        HotKeyWindow.DestroyHandle();
                    }
                    HotKeyWindow = null;
                }

                IsRegistered = true;
            }
            catch
            {
                if (HotKeyWindow.Handle != IntPtr.Zero)
                {
                    HotKeyWindow.DestroyHandle();
                }
                HotKeyWindow = null;

                IsRegistered = false;
            }

            return(IsRegistered);
        }