我想在屏幕上移动矩形。 这是代码,我所做的同时:如何用鼠标移动矩形
internal class GraphicContainer : Control
{
//---------------------METHODS---------------------
public GraphicContainer(Control control, string text, int left, int top)
: base(control, text, left, top, 400, 200)
protected override void OnPaint(PaintEventArgs pe)
{
// Call the OnPaint method of the base class.
base.OnPaint(pe);
// Declare and instantiate a new pen.
Pen pen = new Pen(Color.Fuchsia, 15);
SolidBrush myBrush= new System.Drawing.SolidBrush(Color.HotPink);
// Draw an aqua rectangle in the rectangle represented by the control.
//pe.Graphics.DrawRectangle(pen, new Rectangle(this.Location,this.Size));
Rectangle blublublu = new Rectangle(this.Location, this.Size - new Size(25, 25));
pe.Graphics.DrawRectangle(pen,blublublu);
pe.Graphics.FillRectangle(myBrush,blublublu);
}
protected override void OnMouseMove(MouseEventArgs e)
{
}
protected override void OnClick(EventArgs e)
{
}
}
我搜索了很多,并没有发现我应该写什么代码“的OnMouseMove”和“点击”,以使鼠标移动。
为什么不直接存储OnMouseMove中给定的坐标,并用它们来填充blublublu – Rob
听起来像某种Drag'n'Drop。在野外有很多教程。 – TGlatzer