private void Form1_MouseDown(object sender,System.Windows.Forms.MouseEventArgs e)
{
MessageBox.Show("当前坐标是"+e.X.ToString()+"   "+e.Y.ToString());
}

解决方案 »

  1.   

    Point p = Control.PointToClient([Point]) 将指定屏幕点的位置计算成工作区坐标。
    Point p = Control.PointToScreen([Point]) 将指定工作区点的位置计算成屏幕坐标。
      

  2.   

    一楼是相对坐标,绝对坐标
    void Button_Click(Object o,MouseEventArgs e)
    {
    MessageBox.Show((this.DesktopLocation .X+e.X).ToString());
    MessageBox.Show((this.DesktopLocation .X+e.Y).ToString()); }
      

  3.   

    参考
    http://www.c-sharpcorner.com/Code/2002/April/ScreenCaptureUtility.asp
      

  4.   

    bitsbird(一瓢,生活就是折腾) 兄:
    我另外开个帖给分你吧!这个贴上面的分留给其他兄弟给意见和UP!
    谢谢了 一直写WEBFROM的 突然老板要偶用CS C#写个选择区域调色的
      

  5.   

    画多边形:
                               GraphicsPath path=new GraphicsPath();
    path.AddLines(new Point[]{new Point(100,100),
    new Point(200,200),new Point(500,50),
                               new Point(100,100)});
    path.CloseFigure();
    path.AddLines(new Point[]{new Point(100,600),new Point(200,600),
    new Point(150,700),new Point(100,600)});
    path.CloseFigure();
    Graphics g=this.CreateGraphics();
    g.FillRectangle(Brushes.White,this.ClientRectangle);
    g.DrawPath(Pens.Black,path);
    填充多边形:FillRegion()可以直接填充多个多边形,只要其中的各多边形依次闭合。
      

  6.   

    若要用纯色填充形状,请创建 SolidBrush 对象,然后将其作为一个参数传递给 Graphics 类的某个填充方法。下面的示例显示如何用红色填充椭圆:SolidBrush solidBrush = new SolidBrush(
       Color.FromArgb(255, 255, 0, 0));
    e.Graphics.FillEllipse(solidBrush, 0, 0, 100, 60);在上面的代码中,SolidBrush 构造函数将 Color 对象作为它的唯一参数。Color.FromArgb 方法使用的值分别表示颜色的 alpha、红色、绿色和蓝色分量。这些值中的每一个都必须在 0 到 255 之间。第一个 255 表示颜色是完全不透明的,第二个 255 表示红色分量的强度达到最大。两个零表示绿色和蓝色分量的强度为 0。传递给 FillEllipse 方法的四个数字 (0, 0, 100, 60) 指定该椭圆的外接矩形的位置和尺寸。该矩形的左上角位于 (0, 0),宽度为 100,高度为 60。
      

  7.   

    MSDN帮助 .net框架/使用.net框架编程/绘制和编辑图像
    有不少好东东
      

  8.   

    大家继续 
    要解决的实际问题是:通过获取点的坐标 确定区域后给此区域调色
    我的思路中的问题:
          1.如何记录点坐标
          2.通过记录的点坐标如何确定被选择的区域
          3.前一个点和后一个点用虚线相连 最后一个点与第一个点用虚线相连
                   ...
    要是兄弟们有其他思路解决实际问题的方法也请说出来 
    (bitsbird(一瓢,生活就是折腾) 兄的分在外面给 这儿的分留给你们 谢了)
      

  9.   

    MSDN帮助 .net框架/使用.net框架编程/绘制和编辑图像
    =============================
     bitsbird(一瓢,生活就是折腾) 兄:
    这我昨天看过了 呵呵 看的要睡觉 我就一个字“懒”
    兄弟到http://community.csdn.net/Expert/topic/3364/3364229.xml?temp=.4197504去拿分啊 
    这个帖上面的分给其他兄弟吧 :)
      

  10.   

    private void Form1_MouseDown(object sender,System.Windows.Forms.MouseEventArgs e)
    {
    MessageBox.Show("当前坐标是"+e.X.ToString()+","+e.Y.ToString());
    }
      

  11.   

    首先用楼上几位老兄的方法把顶点的坐标取到,然后通过<、>、&&等运算符将调色区域的范围卡出来,例如:(x1,y1),(x2,y2),(x3,y3)这个三角形,其范围内的点坐标用(a,b)表示,用a>x1&&a<x2&&b>y1&&b<y2这样的方法将窗体内符合以上条件的范围挑选出来不就行了,然后再调色!!
      

  12.   

    我在FLASH里面曾见过这样得例子, bitsbird(一瓢,生活就是折腾) 所说的方法极是,我想你不仅画三角型那么简单吧,
    bitsbird(一瓢,生活就是折腾) 有大师风度,“未解决问题,受之有愧"
      

  13.   

    只会web编程 windows的爱莫能助啊
      

  14.   

    我只会winform,不会webform:)
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Drawing.Drawing2D;
    namespace softchaoWinApp
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
            private System.Collections.ArrayList pntsArray=new ArrayList();
    private System.Collections.ArrayList linesArray=new ArrayList();
    private System.Drawing.Point lastMovePnt=Point.Empty;
    private System.Drawing.Pen  dashPen;
    private System.Drawing.Pen solidPen;
    private bool bClosed=false;
    public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    dashPen=new Pen(Brushes.Black,1);
    dashPen.DashStyle=DashStyle.Dash;
    solidPen=new Pen(this.BackColor,1);
    solidPen.DashStyle=DashStyle.Dash;
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    if(dashPen!=null)
    dashPen.Dispose();
    if(solidPen!=null)
    solidPen.Dispose();
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(536, 438);
    this.Name = "Form1";
    this.Text = "Form1";
    this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
    this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
    this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp);
    this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {

    int lastIndex=pntsArray.Count-1;
    if(lastIndex==-1)
    return;
    Graphics g=this.CreateGraphics();
    if(lastMovePnt!=Point.Empty)
        g.DrawLine(solidPen,(Point)pntsArray[lastIndex],lastMovePnt);
    g.DrawLine(dashPen,(Point)pntsArray[lastIndex],new Point(e.X,e.Y));
    lastMovePnt=new Point(e.X,e.Y);
    drawLines(g);
    g.Dispose();


    } private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    if(e.Button!=MouseButtons.Left||bClosed)
    return;
    pntsArray.Add(new Point(e.X,e.Y));
    }
    private void drawLines(System.Drawing.Graphics g)
    {
    int numPnts;
    foreach(object o in linesArray)
    {
    GraphicsPath path=(GraphicsPath)o;
    g.FillPath(Brushes.Blue,path);
    g.DrawPath(Pens.Black,path);

    }
    if(pntsArray!=null)
    {
    numPnts=pntsArray.Count;
    if(numPnts>1)
    {
    for(int i=0;i<numPnts-1;i++)
    g.DrawLine(this.dashPen,(Point)pntsArray[i],(Point)pntsArray[i+1]);
    if(bClosed)
    {
    g.DrawLine(dashPen,(Point)pntsArray[numPnts-1],(Point)pntsArray[0]);
    g.DrawLine(solidPen,(Point)pntsArray[numPnts-1],lastMovePnt);
    ResetArray();
    }

    }
    }
    g.DrawString("使用鼠标左键确定点,移动鼠标确定线段方向,回车键退出绘制",this.Font,Brushes.Black,new PointF(2,2));
    }
    private void ResetArray()
    {
    drawField();
    this.pntsArray.Clear();
    bClosed=false;
    }
    private void drawField()
    {
    GraphicsPath path=new GraphicsPath();
    path.AddLines((Point[])pntsArray.ToArray(typeof(Point)));
    path.CloseFigure();
    Graphics g=this.CreateGraphics();
    g.FillPath(Brushes.Blue,path);
    g.DrawPath(Pens.Black,path);

    g.Dispose();
    linesArray.Add(path);
    }
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        base.OnPaint(e);

    drawLines(e.Graphics);
    } private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
    if(e.KeyChar==13)
    bClosed=true;

    }
    }
    }
      

  15.   

    Point[] points;
    int num;
    public Form1_Load()  // 初始化
    {
        points = new Point[3];
        num = 0;
    }
    private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
        points[num].X = e.X;
        points[num].Y = e.Y;
        num ++;
        if( num >= 4)
        {
            // 三个点取完了,在 points 中。
            num = 0;
        }
    }
      

  16.   

    Point[] points;  // 保存三个点
    int num;
    public Form1_Load()  // 初始化
    {
        points = new Point[3];
        num = 0;
    }
    ////////////  上一个帖子下面一行错了,
    private void Main1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
        points[num].X = e.X;
        points[num].Y = e.Y;
        num ++;
        if( num >= 4)
        {
            // 三个点取完了,在 points 中。
            num = 0;
        }
    }