/// <summary> /// Displays the context menu. /// </summary> /// <param name="control">A Control that specifies the control with which this context menu is associated.</param> /// <param name="position">A Point that specifies the coordinates at which to display the menu. These coordinates are specified relative to the client coordinates of the control specified in the control parameter.</param> /// <param name="specialFolder">A SpecialFolder to show the context menu for.</param> /// <returns>One of the ContextMenuResult values.</returns> /// <exception cref="System.ArgumentNullException">The control parameter is null.</exception> /// <exception cref="System.ArgumentException">The handle of the control does not exist or the control is not visible.</exception> public ContextMenuResult Show(Control control, Point position, Environment.SpecialFolder specialFolder) { if (control == null) { throw new ArgumentNullException("control"); } if ((!control.IsHandleCreated || !control.Visible)) { throw new ArgumentException("ShellContextMenu cannot be shown on an invisible control."); } Point screenPosition = control.PointToScreen(position); internalShellContextMenu iscm = new internalShellContextMenu(this, control.Handle, screenPosition); return(iscm.Show(specialFolder)); }
/// <summary> /// Displays the context menu. /// </summary> /// <param name="control">A Control that specifies the control with which this context menu is associated.</param> /// <param name="position">A Point that specifies the coordinates at which to display the menu. These coordinates are specified relative to the client coordinates of the control specified in the control parameter.</param> /// <param name="path">A FileSystemInfo object representing the path that the context menu is being displayed for.</param> /// <returns>One of the ContextMenuResult values.</returns> /// <exception cref="System.ArgumentNullException">The control parameter is null, or the path parameter is null.</exception> /// <exception cref="System.ArgumentException">The handle of the control does not exist or the control is not visible.</exception> public ContextMenuResult Show(Control control, Point position, FileSystemInfo path) { if (control == null) { throw new ArgumentNullException("control"); } if ((!control.IsHandleCreated || !control.Visible)) { throw new ArgumentException("ShellContextMenu cannot be shown on an invisible control."); } if (path == null) { throw new ArgumentNullException("path"); } Point screenPosition = control.PointToScreen(position); internalShellContextMenu iscm = new internalShellContextMenu(this, control.Handle, screenPosition); return(iscm.Show(new FileSystemInfo[] { path })); }