获取单击按钮后鼠标单击的坐标

本文关键字:单击 坐标 鼠标 按钮 获取 | 更新日期: 2023-09-27 17:53:16

我正在使用c#为Ms-Word开发一个插件,我想要的只是在单击按钮后获得下一次单击的坐标。

Thanks in Advance.

//This is the Click
public void ClickRibbon(Office.IRibbonControl control){
     //After this, we have to read a next Click anywhere on the Form whose coordinates needs to be determined
}

获取单击按钮后鼠标单击的坐标

希望对您有所帮助。

    bool TrackFlag = false;
    public void ClickRibbon(Office.IRibbonControl control)
    {
        TrackFlag = true;
    }
    private void Form1_Click(object sender, EventArgs e)
    {
        if (TrackFlag)
        {
            TrackFlag = false;
            int x = MousePosition.X;
            int y = MousePosition.Y;
            MessageBox.Show("Location (x,y) (" + x + "," + y + ")");
        }
    }