示例#1
0
        void _cmsDynamic_Opened(object sender, EventArgs e)
        {
            _cmsDynamic.Opened -= new EventHandler(_cmsDynamic_Opened);

            Point ptButton = PointToScreen(btnOK.Location);
            Point ptMenu   = _cmsDynamic.PointToScreen(_cmsDynamic.DisplayRectangle.Location);

            Screen scButton = Screen.FromPoint(ptButton);
            Screen scMenu   = Screen.FromPoint(ptMenu);

            if (scButton != null && scMenu != null &&
                scButton.DeviceName != scMenu.DeviceName)
            {
                int dx = ptButton.X - ptMenu.X;

                Point p = new Point(dx, btnOK.Height);
                _cmsDynamic.Show(btnOK, p, ToolStripDropDownDirection.Default);
            }
        }
        public Tuple <int, int> GetContextMenuPosition()
        {
            Point p = ContextMenuStrip.PointToScreen(new Point(0, 0));

            return(new Tuple <int, int>(p.X, p.Y));
        }