B
bluebirds
Unregistered / Unconfirmed
GUEST, unregistred user!
以下用鼠标画矩形框的程序在delphi5下可以运行,在delphi6下只要点击并拖动鼠标,
屏幕总是闪烁,难道必须放弃delphi6?
var
Form1: TForm1;
oldx,oldy,newx,newy:integer;
drawing:boolean=false;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
image1.Canvas.FillRect(image1.BoundsRect);
oldx:=0;
oldy:=0;
newx:=0;
newy:=0;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if(not drawing)then
begin
if(oldx<>newx)then image1.Canvas.Rectangle(oldx,oldy,newx,newy);
oldx:=x;
newx:=x;
oldy:=y;
newy:=y;
drawing:=true;
image1.Canvas.Pen.Mode:=pmnot;
image1.Canvas.Brush.Style:=bsclear;
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if drawing then
begin
image1.Canvas.Rectangle(oldx,oldy,newx,newy);
newx:=x;
newy:=y;
image1.Canvas.Rectangle(oldx,oldy,newx,newy);
end;
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if drawing then drawing:=false;
end;
屏幕总是闪烁,难道必须放弃delphi6?
var
Form1: TForm1;
oldx,oldy,newx,newy:integer;
drawing:boolean=false;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
image1.Canvas.FillRect(image1.BoundsRect);
oldx:=0;
oldy:=0;
newx:=0;
newy:=0;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if(not drawing)then
begin
if(oldx<>newx)then image1.Canvas.Rectangle(oldx,oldy,newx,newy);
oldx:=x;
newx:=x;
oldy:=y;
newy:=y;
drawing:=true;
image1.Canvas.Pen.Mode:=pmnot;
image1.Canvas.Brush.Style:=bsclear;
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if drawing then
begin
image1.Canvas.Rectangle(oldx,oldy,newx,newy);
newx:=x;
newy:=y;
image1.Canvas.Rectangle(oldx,oldy,newx,newy);
end;
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if drawing then drawing:=false;
end;