Exemplo n.º 1
0
    protected void GrabTheFocus()
    {
      oldFocus = WindowsAPI.GetFocus();

      // Is the focus on a control/window?
      if ( oldFocus != IntPtr.Zero)
      {
        IntPtr hParent = WindowsAPI.GetParent( oldFocus);

        // Did we find a parent window?
        if (hParent != IntPtr.Zero)
        {
          // Create a new destination for the focus
          focusCatcher = new FocusCatcher(hParent);

          // Park focus at the temporary window
          WindowsAPI.SetFocus( focusCatcher.Handle);

          // Kill any capturing of the mouse
          WindowsAPI.ReleaseCapture();
        }
      }

      grabFocus = false;
    }
Exemplo n.º 2
0
    protected void ReturnTheFocus()
    {
      // Restore focus to origin
      WindowsAPI.SetFocus( oldFocus);
      
      // Did we use an temporary parking location?
      if ( focusCatcher != null)
      {
        // Kill it
        focusCatcher.DestroyHandle();
        focusCatcher = null;
      }

      // Reset state
      oldFocus = IntPtr.Zero;
    }
Exemplo n.º 3
0
    public PopupMenu()
    {
      // Create collection objects
      drawCommands = new ArrayList();
      menuCommands = new MenuCommandCollection(); 

      // Default the properties
      returnDir = 0;
      extraSize = 0;
      popupItem = -1;
      trackItem = -1;
      childMenu = null;
      exitLoop = false;
      popupDown = true;
      mouseOver = false;
      grabFocus = false;
      excludeTop = true;
      popupRight = true;
      parentMenu = null;
      excludeOffset = 0;
      focusCatcher = null;
      parentControl = null;
      returnCommand = null;
      oldFocus = IntPtr.Zero;
      showInfrequent = false;
      style = VisualStyle.IDE;
      lastMousePos = new Point(-1,-1);
      direction = Direction.Horizontal;
      textFont = SystemInformation.MenuFont;

      // Create and initialise the timer object (but do not start it running!)
      timer = new Timer();
      timer.Interval = selectionDelay;
      timer.Tick += new EventHandler(OnTimerExpire);
    }