The easiest way (since this is not the actual menu) is to create a borderless form and add a shadow to it:
public class ShadowForm : Form {
As for the situation, this is not enough. Just check Cursor.Position or set the coordinates using the arguments in the MouseUp event MouseUp .
The full code will look something like this:
public partial class ParentForm : Form { public ParentForm() { InitializeComponent(); } protected override OnMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var menu = new CustomMenu(); menu.Location = PointToScreen(e.Location); menu.Show(this); } } }
and for the "menu" form:
public partial class CustomMenu : Form { public CustomMenu() { InitializeComponent(); this.StartPosition = FormStartPosition.Manual; } private const int CS_DROPSHADOW = 0x00020000; protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ClassStyle |= CS_DROPSHADOW; return cp; } } protected override void OnLostFocus(EventArgs e) { this.Close(); base.OnLostFocus(e); } }
source share