谢了,有没有例子我看一下,对这个一无所知,学winform不久,请高手指点一下!
解决方案 »
- 如何递归实现一个对象的序列化
- openfiledialog在屏幕上的显示位置啊?
- 关于图像自动切片,高手请进!
- 为什么DataList1是一片空白? 我做错了什么?55555
- 一个简单的Com引用问题!
- C#做的群发邮件软件,线程自动调用,在服务器上发了几百封后就没反应了,请问高手是何原因?急!!!!!
- 语法问题: using (StreamReader sr = File.OpenText(path))是什么意思
- 戴志康: 一个23岁的年轻人 一名在读的大四学生 一个三年30万的程序员 一家中关村新创软件公司的CEO
- 求高效图像处理算法
- c#插入数据的时候出现的问题请高手指点。
- 求从注册表提取软件安装卸载信息的规则
- 线程终止问题
intY = e.Y;)在鼠标弹起的时候,记住这个点。利用这两个点计算。画好以后。不刷新的话。是不显示的。
public partial class Form1 : Form
{
Point startPoint;
Rectangle lastRect;
bool isDragging; public Form1()
{
InitializeComponent();
} protected override void OnMouseDown(MouseEventArgs e)
{
startPoint = this.PointToScreen(e.Location);
lastRect = new Rectangle(0, 0, 0, 0);
isDragging = true;
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (isDragging )
{
Point current = this.PointToScreen(e.Location);
int width = current.X - startPoint.X;
int height = current.Y - startPoint.Y; ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed);
lastRect = new Rectangle(startPoint, new Size(width, height));
ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed);
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
if (isDragging)
{
isDragging = false;
ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed); MessageBox.Show("the rect is " + lastRect);
}
}
}
From: GDI +画橡皮线的问题
看看这个吧!应该就是你想要的
然后记录下来作为你矩形的长和宽