Ejemplo n.º 1
0
        /// <include file='doc\OleMenuCommandService.uex' path='docs/doc[@for="OleMenuCommandService.ShowContextMenu"]/*' />
        /// <devdoc>
        ///     Shows the context menu with the given command ID at the given
        ///     location.
        /// </devdoc>
        public override void ShowContextMenu(CommandID menuID, int x, int y)
        {
            IOleComponentUIManager cui = GetService(typeof(NativeMethods.OleComponentUIManager)) as IOleComponentUIManager;

            Debug.Assert(cui != null, "no component UI manager, so we can't display a context menu");
            if (cui != null)
            {
                POINTS[] pt = new POINTS[] { new POINTS() };
                pt[0].x = (short)x;
                pt[0].y = (short)y;

                Guid tmpGuid = menuID.Guid;
                NativeMethods.ThrowOnFailure(cui.ShowContextMenu(0, ref tmpGuid, menuID.ID, pt, this));
            }
        }
Ejemplo n.º 2
0
        /// <include file='doc\MenuCommandService.uex' path='docs/doc[@for="MenuCommandService.ShowContextMenu"]/*' />
        /// <devdoc>
        ///     Shows the context menu with the given command ID at the given
        ///     location.
        /// </devdoc>
        public void ShowContextMenu(CommandID menuID, int x, int y)
        {
            if (serviceProvider == null)
            {
                return;
            }
            IOleComponentUIManager cui = (IOleComponentUIManager)serviceProvider.GetService(typeof(OleComponentUIManager));

            Debug.Assert(cui != null, "no component UI manager, so we can't display a context menu");
            if (cui != null)
            {
                tagPOINTS pt = new tagPOINTS();
                pt.x = (short)x;
                pt.y = (short)y;

                Guid tmpGuid = menuID.Guid;
                cui.ShowContextMenu(0, ref tmpGuid, menuID.ID, pt, this);
            }
        }