如何在onpain事件的时候获取鼠标所在的位置?

来源:百度知道 编辑:UC知道 时间:2024/05/27 14:38:23
protected override void OnPaint(PaintEventArgs e)
如何在onpain事件的时候获取鼠标所在的位置?

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
System.Diagnostics.Debug.WriteLine(Cursor.Position.ToString());
base.OnPaint(e);
}

Cursor.Position就是mouse位置,一般情况下,Cursor位置与mouse相同
在是在WinForm中,在WebForm中用js好一些