我的图象操作代码,怎么改变图象大小以后,拖动图象象拉粘皮糖一样啊~~~~~~(50分)

I

icehill

Unregistered / Unconfirmed
GUEST, unregistred user!
{--------------------------------Move the picture------------------------------------------}
procedure TForm_3011.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
MouseDown.x:=x;
MouseDown.y:=y;
Capture:=true;
end;
{--------------------------------Move the picture----------------------------------------}
procedure TForm_3011.Image1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if Capture then
begin
so.HorzScrollBar.Position := so.HorzScrollBar.Position+trunc((X-MouseDown.x)/20);
so.VertScrollBar.Position := so.VertScrollBar.Position+trunc((Y-MouseDown.y)/20);
end;
end;
{-------------------------------Move the picture-----------------------------------------}
procedure TForm_3011.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Capture then
begin
Capture:=false;
so.HorzScrollBar.Position := so.HorzScrollBar.Position+trunc((X-MouseDown.x)/20);
so.VertScrollBar.Position := so.VertScrollBar.Position+trunc((Y-MouseDown.y)/20);
end;
end;

{------------------------------------------------------------------------}
procedure TForm_3011.BitBtn1Click(Sender: TObject);
begin
Image1.AutoSize:=false;
Image1.Stretch:=true;
Image1.Height:=trunc(Image1.Height*2/3);
Image1.Width:=trunc(Image1.Width*2/3);
end;

{----------------------------------------------------------------------}
procedure TForm_3011.BitBtn2Click(Sender: TObject);
begin
Image1.AutoSize:=false;
Image1.Stretch:=true;
Image1.Height:=trunc(Image1.Height*3/2);
Image1.Width:=trunc(Image1.Width*3/2);
end;

procedure TForm_3011.FormActivate(Sender: TObject);
begin
so.DoubleBuffered:=true;
end;

 
我给你改了一下,你在mousemove和mouseup中的增加量不对
{--------------------------------Move the picture------------------------------------------}
procedure TForm_3011.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
MouseDown.x:=x;
MouseDown.y:=y;
Capture:=true;
end;
{--------------------------------Move the picture----------------------------------------}
procedure TForm_3011.Image1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if Capture then
begin
so.HorzScrollBar.Position := so.HorzScrollBar.Position+trunc((X-MouseDown.x)/20);
so.VertScrollBar.Position := so.VertScrollBar.Position+trunc((Y-MouseDown.y)/20);
MouseDown.x:=X;//增加
MouseDown.y:=Y;//增加
end;
end;
{-------------------------------Move the picture-----------------------------------------}
procedure TForm_3011.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Capture then
begin
Capture:=false;
so.HorzScrollBar.Position := so.HorzScrollBar.Position+trunc((X-MouseDown.x)/20);
so.VertScrollBar.Position := so.VertScrollBar.Position+trunc((Y-MouseDown.y)/20);
end;
end;
 
Image1.Stretch = true就会那样,很烦的
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
661
import
I
I
回复
0
查看
514
import
I
I
回复
0
查看
531
import
I
I
回复
0
查看
575
import
I
I
回复
0
查看
585
import
I
顶部