CF - How to get mouse position when ContextMenu pops up ??

Posted by no9 on Stack Overflow See other posts from Stack Overflow or by no9
Published on 2010-05-20T06:25:42Z Indexed on 2010/05/20 6:30 UTC
Read the original article Hit count: 335

I have a problem i cannot solve.

In my view (that shows a map) i created a contextMenu. When context menu is invoked i need to get the position where the user has clicked on the map.

Here is my problem:

In the view i already have onMouseDown event that gets me the coordinates where the user clicked.

private void MapView_MouseDown(object sender, MouseEventArgs e)
    {
        this.lastMouseDownX = e.X;
        this.lastMouseDownY = e.Y;
    }

When the contextMenu is invoked i need the same data, but the problem is that contextMenu only has EventArgs that dont keep the data i need. Furthermore ... contextMenu is invoked when user presses and holds mouse for a second and when its invoked the code does not enter onMouseDown event ! It just goes into popup event on my context menu....

I tried putting this in my popup event, but the coordinates are not ok. Y coordinate is way off the chart.

private void servicesContextMenu_Popup(object sender, EventArgs e)
{
    this.lastMouseUpX = Control.MousePosition.X;
    this.lastMouseUpX = Control.MousePosition.Y;
}

I also tried this, but with no success ... the problem remains ... when contextMenu is invoked the code does not fire onMouseDown event.

http://www.mofeel.net/58-microsoft-public-dotnet-framework-compactframework/19285.aspx

Help?

© Stack Overflow or respective owner

Related posts about compact-framework

Related posts about contextmenu