这100分,我要了,呵呵,我刚做了个能符合你要求的。
1、先判断鼠标是否点在图象中
function PointInRect(x,y:integer;rect1:TRect):boolean;
begin
if(x>rect1.left)and(x<rect1.right)and(y>rect1.top)
and(y<rect1.bottom) then
result:=true;
end;
procedure TForm.ImageMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
DragFlag:=(PointInRect(x,y,Rect(Image1.topleft,Image1.RightBottom));//DragFlag为是否点中的标志
end;
2、如果点中的话,就在mousemove时画方框
procedure TForm.ImageMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
Rectangle(Image1.left,image1.top,image1.Bottom,image1.Right);
Image1.left:=Image1.left +x-BeforeMovePoint.x;
image1.top:=image1.top +y-BeforeMovePoint.y;
BeforeMovePoint:=Point(x,y);
Rectangle(Image1.left,image1.top,image1.Bottom,image1.Right);
end;
3、最后在mouseup时,再把图形显示回来
DrawImage.Canvas.Draw(Image1.left,Image1.Left.Y,Image1);
ps.上面可能讲的不是很详细,也有点小错,不过实现的思路就是这样的。