Esempio n. 1
0
    protected void OperateSubMenu(int popupItem, bool selectFirst)
    {
      popupItem = popupItem;
      childMenu = new PopupMenu();

      DrawCommand dc =  drawCommands[popupItem] as DrawCommand;

      // Find screen coordinate of Top right of item cell
      Win32.POINT screenPosTR;
      screenPosTR.x = dc.DrawRect.Right;
      screenPosTR.y = dc.DrawRect.Top;
      WindowsAPI.ClientToScreen(this.Handle, ref screenPosTR);
      
      // Find screen coordinate of top left of item cell
      Win32.POINT screenPosTL;
      screenPosTL.x = dc.DrawRect.Left;
      screenPosTL.y = dc.DrawRect.Top;
      WindowsAPI.ClientToScreen(this.Handle, ref screenPosTL);

      // Ensure the child has the same properties as ourself
      childMenu.Style = this.Style;
      childMenu.Font = this.Font;

      // Record keyboard direction
      int returnDir = 0;

      returnCommand =  childMenu.InternalTrackPopup(new Point(screenPosTR.x, screenPosTR.y),
        new Point(screenPosTL.x, screenPosTL.y), 
        dc.MenuCommand.MenuCommands, 
        this, 
        selectFirst,
        parentControl,
        popupRight,
        popupDown,
        ref returnDir);

      popupItem = -1;;
      childMenu = null;

      if (( returnCommand != null) || (returnDir != 0))
      {
        // Finish processing messages
        timer.Stop();
        exitLoop = true;  
        returnDir = returnDir;
      }
    }