想让图片在TImage内移动,而且平滑,无刷屏感觉
解决方案 »
- 用ADO连接 sql2000出现的列名“xxx”无效 的问题,在线等。。。谢谢
- 主程序调用DLL窗体 cannot assign a TFont to a TFont 问题的彻底解决方案
- 请教ADOQuery1 模糊查询
- 关于表的复制问题,正确马上给分,分不够可以再加,哪位好心人帮帮忙呢
- 有厦门的delphi QQ群吗?
- 有没有完全免费的条码打印控件
- 关于扩展名为DCR的文件问题50分相送!!!!!
- 关于当前路径以及书的问题。
- 请教各位!如何实现像winamp从程序外向播放列表中拖曳文件的功能???这样的功能难不难实现???
- 在delphi中关键字能否体现出颜色。
- 两个窗口如何传递?
- 你进来了吗?
研究TImage呢?
unit MainFrm; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls; type
TForm1 = class(TForm)
Image1: TImage;
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
FBitmap: TBitmap;
FDownFlag: Boolean;
FLastPoint: TPoint;
FDrawPos: TPoint;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end; var
Form1: TForm1; implementation {$R *.dfm} { TForm1 } constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
FBitmap := TBitmap.Create;
FBitmap.LoadFromFile('About.bmp');
Image1.Picture.Graphic := FBitmap;
DoubleBuffered := True;
end; destructor TForm1.Destroy;
begin
FBitmap.Free;
inherited;
end; procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
FDownFlag := True;
FLastPoint := Point(X, Y);
end; procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
dx, dy: Integer;
begin
if FDownFlag then
begin
dx := X - FLastPoint.X;
dy := Y - FLastPoint.Y;
Inc(FDrawPos.X, dx);
Inc(FDrawPos.Y, dy);
Image1.Picture.Graphic := nil;
Image1.Canvas.Draw(FDrawPos.X, FDrawPos.Y, FBitmap);
FLastPoint := Point(X, Y);
end;
end; procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
FDownFlag := False;
end; end.