c#各处鼠标的相对位置

常用到的

1. System.Windows.Forms.Cursor中Position对应的是与屏幕的相对位置

APointthat represents the cursor's position in screen coordinates.

http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx

2.System.Windows.Forms.MouseEventArgs.X,Y对应的有可能是与触发事件的控件的相对位置,也有可能是与屏幕的相对位置

The mouse coordinates vary based on the event being raised. For example, when theControl.MouseMoveevent is handled, the mouse coordinate values are relative to the coordinates of the control that raised the event. Some events related to drag-and-drop operations have associated mouse-coordinate values that are relative to the form origin or the screen origin.

http://msdn.microsoft.com/en-us/library/system.windows.forms.mouseeventargs.x.aspx

3. 使用Graphics g = this.CreateGraphics();来画图时,提供的x,y位值为this的相对位置

你可能感兴趣的:(C++,c,windows,C#,Microsoft)