放在TScrollBox是最简单,最直接的。当然漫游才是最爽的!
方法是:
在窗体上放置一TPanel,然后在TPanel上放置一TImage,再将一TLabel放入TPanel中,
TLabel的设置如下:
Align = AlClient;
Transparent = True;
Caption = '';
var
origin:tpoint;
image_left:integer;
image_top:integer;
visa1:tpoint;
visa2:tpoint;
canmove:boolean;
procedure TDraftForm.Label7MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft then
begin
origin.X:=x;
origin.Y:=y;
image_left:=image1.Left;
image_top:=image1.Top;
visa1.X:=x-(image1.Width-panel5.Width+image1.Left);
visa1.Y:=y-(image1.Height-panel5.Height+image1.Top);
visa2.X:=x-image1.Left;
visa2.Y:=y-image1.Top;
canmove:=true;
end;
procedure TDraftForm.Label7MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if canmove then
begin
if x<visa1.X then x:=visa1.X;
if x>visa2.X then x:=visa2.X;
if y<visa1.Y then y:=visa1.Y;
if y>visa2.Y then y:=visa2.Y;
image1.Left:=image_left+(x-origin.X);
image1.Top:=image_top+(y-origin.Y);
end;
end;
procedure TDraftForm.Label7MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
canmove:=false;
end;
这样你就可以象AcdSee一样用鼠标拉着图象漫游了。