开发者

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

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 cl开发者_JS百科icked 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.lastMouseDownX = Control.MousePosition.X;
    this.lastMouseDownX = Control.MousePosition.Y;
}

Help?


Using this helped me get things done.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜