示例#1
0
 public static void RegisterHotKey(Form f, Keys key)
 {
     int modifiers = 0;
     if ((key & Keys.Alt) == Keys.Alt)
         modifiers = modifiers | MOD_ALT;
     if ((key & Keys.Control) == Keys.Control)
         modifiers = modifiers | MOD_CONTROL;
     if ((key & Keys.Shift) == Keys.Shift)
         modifiers = modifiers | MOD_SHIFT;
     Keys k = key & ~Keys.Control & ~Keys.Shift & ~Keys.Alt;
     keyId = f.GetHashCode(); // this should be a key unique ID, modify this if you want more than one hotkey
     RegisterHotKey(f.Handle, keyId, (uint)modifiers, (uint)k);
 }
示例#2
0
        public static void RegisterHotKey(Form f, int hotkey, bool ctrl, bool alt, bool shift, bool launcher)
        {
            int modifiers = 0;

            if (ctrl)
                modifiers = modifiers | MOD_CONTROL;
            if (alt)
                modifiers = modifiers | MOD_ALT;
            if (shift)
                modifiers = modifiers | MOD_SHIFT;

            if (!launcher)
            {
                keyId = f.GetHashCode();
                RegisterHotKey((IntPtr)f.Handle, keyId, modifiers, hotkey);
            }
            else
            {
                launcherKeyId = f.GetHashCode() + 1;
                RegisterHotKey((IntPtr)f.Handle, launcherKeyId, modifiers, hotkey);
            }
        }
示例#3
0
        public static void RegisterHotKey(Form f, Keys key)
        {
            var modifiers = 0;

            if ((key & Keys.Alt) == Keys.Alt)
                modifiers = modifiers | ModAlt;

            if ((key & Keys.Control) == Keys.Control)
                modifiers = modifiers | ModControl;

            if ((key & Keys.Shift) == Keys.Shift)
                modifiers = modifiers | ModShift;

            var k = key & ~Keys.Control & ~Keys.Shift & ~Keys.Alt;
            _keyId = f.GetHashCode(); // this should be a key unique ID, modify this if you want more than one hotkey
            RegisterHotKey(f.Handle, _keyId, modifiers, (int) k);
        }
示例#4
0
        public static void RegisterHotKey(Form f, Keys key)
        {
            int modifiers = 0;

            if ((key & Keys.Alt) == Keys.Alt)
                modifiers = modifiers | WindowsShell.MOD_ALT;

            if ((key & Keys.Control) == Keys.Control)
                modifiers = modifiers | WindowsShell.MOD_CONTROL;

            if ((key & Keys.Shift) == Keys.Shift)
                modifiers = modifiers | WindowsShell.MOD_SHIFT;

            Keys k = key & ~Keys.Control & ~Keys.Shift & ~Keys.Alt;

            Func ff = delegate()
                {
                    keyId = f.GetHashCode(); // this should be a key unique ID, modify this if you want more than one hotkey
                    RegisterHotKey((IntPtr)f.Handle, keyId, modifiers, (int)k);
                };

            f.Invoke(ff); // this should be checked if we really need it (InvokeRequired), but it's faster this way
        }
示例#5
0
        public static void Register(Form form, AppBarEdge edge, Screen screen)
        {
            Rectangle screenArea = screen.WorkingArea;
            if (edge == AppBarEdge.Top || edge == AppBarEdge.Bottom)
            {
                form.Left = screenArea.Left;
                form.Width = screenArea.Width;
                form.Top = edge == AppBarEdge.Top ? screenArea.Top : screenArea.Bottom - form.Height;
            }
            else
            {
                form.Left = edge == AppBarEdge.Left ? screenArea.Left : screenArea.Right - form.Width;
                form.Height = screenArea.Height;
                form.Top = screenArea.Top;
            }
            form.FormBorderStyle = FormBorderStyle.None;
            uint callbackId = RegisterWindowMessage(form.GetHashCode().ToString("x"));

            APPBARDATA appData = new APPBARDATA();
            appData.cbSize = (uint)Marshal.SizeOf(appData);
            appData.uCallbackMessage = callbackId;
            appData.hWnd = form.Handle;

            uint ret = SHAppBarMessage(AppBarMessage.New, ref appData);
            if (ret != 0)
            {
                _appBars.Add(form);
                form.FormClosing += (s, e) => Unregister(form);
                AppBarPosition(form, edge, AppBarMessage.QueryPos);
                AppBarPosition(form, edge, AppBarMessage.SetPos);
            }
        }
示例#6
0
 /// <summary>
 /// Add new form as docking pane
 /// </summary>
 /// <param name="NewObject">Form to add</param>
 private Pane CreateDockingPane_(Form NewObject)
 {
     Pane RetVal;
       lock (DockingQueue_)
       {
     DockingQueue_.Add(NewObject.GetHashCode(), NewObject);
     RetVal = axDockingPane.CreatePane(NewObject.GetHashCode(), 200, 120, DockingDirection.DockLeftOf, null);
     RetVal.Title = NewObject.Text;
       }
       return RetVal;
 }
示例#7
0
 private static string GetKeyFor(Form form, Control control){
     return string.Format("{0}_{1}", form.GetHashCode(), control.GetHashCode());
 }
示例#8
0
 /// <summary>
 /// When the form dies the TabControls should be released
 /// </summary>
 /// <param name="form">The Form</param>
 public static void ReleaseResources(Form form)
 {
     int code = form.GetHashCode();
     List<TabControl> tabs = FormsWithTabsControlsUsingMnemonic[code];
     foreach (TabControl tab in tabs)
     {
         int tabcode = tab.GetHashCode();
         TabsDisabled.Remove(tabcode);
         TabsVisible.Remove(tabcode);
         ControlOfCustomDrawingMode.Remove(tabcode);
         newProperties.Remove(tabcode);
     }
     FormsWithTabsControlsUsingMnemonic.Remove(code);
 }