private
x1,y1:integer; //拖到目标坐标
aa:boolean; //是否能拖
image_left:integer; //开始拖动时图片的X坐标
image_top:integer; ////开始拖动时图片的Y坐标//====================procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);begin
image_left:=image1.left;
image_top:=image1.top;
X1:=x;
Y1:=y;
aa:=true;
end;//==========
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
aa:=false;
end;
//==============
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);begin
if aa then
begin
image1.left:=image_left+(X-x1);
image1.top:=image_top+(y-y1);
end;
end;怎么会移动的坐标与mouse的坐标不一致阿 明显置后!兄弟们给看看!
x1,y1:integer; //拖到目标坐标
aa:boolean; //是否能拖
image_left:integer; //开始拖动时图片的X坐标
image_top:integer; ////开始拖动时图片的Y坐标//====================procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);begin
image_left:=image1.left;
image_top:=image1.top;
X1:=x;
Y1:=y;
aa:=true;
end;//==========
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
aa:=false;
end;
//==============
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);begin
if aa then
begin
image1.left:=image_left+(X-x1);
image1.top:=image_top+(y-y1);
end;
end;怎么会移动的坐标与mouse的坐标不一致阿 明显置后!兄弟们给看看!
OldX,OldY:Integer;
procedure TEditAndViewForm.imgPicMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ssLeft in Shift then
begin
Screen.Cursor := crHandPoint;
OldX := X;
OldY := Y;
end;
end;procedure TEditAndViewForm.imgPicMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if ssLeft in Shift then
begin
imgPic.Left := imgPic.Left + X - OldX;
if imgPic.Left > 0 then
imgPic.Left := 0
else
if (imgPic.Left + imgPic.Width) < (PlPic.Left + plPic.Width) then
imgPic.Left := plPic.Left + plPic.Width - imgPic.Width;
imgPic.Top := imgPic.Top + Y - OldY;
if imgPic.Top > 0 then
imgPic.Top := 0
else
if (imgPic.Top + imgPic.Height) < (plPic.Top + plPic.Height) then
imgPic.Top := plPic.Top + plPic.Height - imgPic.Height;
end;
end;procedure TEditAndViewForm.imgPicMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Screen.Cursor := crDefault;
imgPic.Left := imgPic.Left + X - OldX;
if imgPic.Left > 0 then
imgPic.Left := 0
else
if (imgPic.Left + imgPic.Width) < (plPic.Left + plPic.Width) then
imgPic.Left := plPic.Left + plPic.Width - imgPic.Width;
imgPic.Top := imgPic.Top + Y - OldY;
if imgPic.Top > 0 then
imgPic.top := 0
else
if (imgPic.Top + imgPic.Height) < (plPic.Top + plPic.Height) then
imgPic.Top := plPic.Top + plPic.Height - imgPic.Height;
end;