How to get mouseposition when context menu appears?
- by ikky
Hi.
I have a panel which holds many pictureboxes. Each picturebox has registered "contextRightMenu" as their context menu.
What i want when the context menu pops up is to get the current mouseposition.
I have tried getting the mouseposition by using mouseDown and click, but these events happens after one of the items of the context menu is clicked, and that is too late.
the popup event of the context menu does not deliver mouse event args, so i don't know how to get the mouseposition.
If i can get mouse event args it is easy.
Then i just can:
this.contextRightClick.Popup += new System.EventHandler(this.contextRightClick_Popup);
// If EventArgs include mouseposition within the sender
private void contextRightClick_Popup)(object sender, EventArgs e)
{
int iLocationX = sender.Location.X;
int iLocationY = sender.Location.Y;
Point pPosition = new Point(iLocationX + e.X, iLocationY + e.Y); // Location + position within the sender = current mouseposition
}
Can anyone help me either get some mouse event args, or suggest a event that will run before the contextmenu pop ups?
Thanks in advance