当我单击窗体以外的地方时,能够获取到鼠标的位置。
谢谢

解决方案 »

  1.   


        {
            this.MouseClick += new MouseEventHandler(Form1_MouseClick);
            this.Capture = true;          //<--- allow you to click outside the form
        }
        void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            Point p = e.Location;         //<--- position
            this.Capture = false;         // stop capturing
        }
      

  2.   

    [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="GetCursorPos")] 
    public static extern int GetCursorPos ( 
    ref POINTAPI lpPoint 
    ); [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)] 
    public struct POINTAPI 

    public int x; 
    public int y; 

    使用
    POINTAPI pt = new POINTAPI(); 
    GetCursorPos(ref pt); 
    this.label1.Text = "x=" + pt.x + " y=" + pt.y; 
      

  3.   

    gomoku 
    获取不了窗体外的,我单击窗体外的任何一个地方的时候都没有反映。
      

  4.   

        POINTAPI pt = new POINTAPI();
                GetCursorPos(ref pt);
               MessageBox.Show( "x=" + pt.x + " y=" + pt.y); 
    哪这个要写在那里呢?
    我是要单击窗体外的地方。如桌面的时候得到坐标。
      

  5.   

    http://blog.csdn.net/a523194491/archive/2008/05/28/2490996.aspx