A
akosboy
Unregistered / Unconfirmed
GUEST, unregistred user!
我在IMAGE中使用鼠标拖出一个矩形框,使用FillRect可以画出,但是使用FrameRect就没反应了,哪位帮我看看这段代码有什么问题,谢谢:)
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ifClick:=true;
iStartX:=x;
iStartY:=y;
end;
***************************************************************************
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if ifClick then
begin
image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'aab.bmp');
image1.Canvas.FillRect(rect(min(iStartX,x),max(iStartY,Y),max(iStartX,X),min(iStartY,Y)));
end;
end;
*************************************************************************
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ifClick then
begin
image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'aab.bmp');
image1.Canvas.FillRect(rect(min(iStartX,x),max(iStartY,Y),max(iStartX,X),min(iStartY,Y)));
ifClick:=false;
end;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ifClick:=true;
iStartX:=x;
iStartY:=y;
end;
***************************************************************************
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if ifClick then
begin
image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'aab.bmp');
image1.Canvas.FillRect(rect(min(iStartX,x),max(iStartY,Y),max(iStartX,X),min(iStartY,Y)));
end;
end;
*************************************************************************
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ifClick then
begin
image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'aab.bmp');
image1.Canvas.FillRect(rect(min(iStartX,x),max(iStartY,Y),max(iStartX,X),min(iStartY,Y)));
ifClick:=false;
end;
end;