image中怎样控制图像的滚动?(20分)

  • 主题发起人 主题发起人 tangyan
  • 开始时间 开始时间
T

tangyan

Unregistered / Unconfirmed
GUEST, unregistred user!
用image控件加载一图片后,由于图片很大,显示不完,我想通过键盘来让图片滚动,比如按‘+’图像就向下滚动10毫米,请教各位大哥我怎么实现呢?最好给点代码,不然我看不懂,谢谢!
 
先放一个TScrollBox,把TImage放在它里头,然后用TScrollBox控制图片的翻滚
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls;

type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
MouseDownPoint,MouseMovePoint :TPoint;
IsMouseDown :Boolean;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
DoubleBuffered:=true;

IsMouseDown :=False;


end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button=mbLeft then
begin
IsMouseDown :=True;
MouseDownPoint :=Point(x,y);
end;

end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if IsMouseDown then
begin
Screen.Cursor := crHandPoint;

MouseMovePoint :=Point(x,y);
Form1.HorzScrollBar.Position :=Form1.HorzScrollBar.Position+MouseDownPoint.x-MouseMovePoint.x;
Form1.VertScrollBar.Position :=Form1.VertScrollBar.Position+MouseDownPoint.y-MouseMovePoint.y;
end;

end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
IsMouseDown :=False;

end;

end.
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
797
DelphiTeacher的专栏
D
D
回复
0
查看
656
DelphiTeacher的专栏
D
D
回复
0
查看
824
DelphiTeacher的专栏
D
D
回复
0
查看
768
DelphiTeacher的专栏
D
后退
顶部