最近想做一个播放器,用两个IMAGE做了度条,其中IMAGE1是滑块,IMAGE2是背景。代码如下:
:
:
var TFrmMain:TForm1;
IsPointDown:Boolean;
:
:
procedure TFrmMain.image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
isPointDown:=True;
end;
procedure TFrmMain.image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if IsPointDown then
begin
if (image1.left+x>=image2.left) and (image1.left<=(image2.left+image2.width)) then
image.Left:=point.Left+x;
end;
end;
procedure TFrmMain.Image1MouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
begin
IsPointDown:=False;
end;
这段代码错是没错,只是不知为何很慢,拖动时很不爽,大家有没有更好的实现方法????