L
liujianan
Unregistered / Unconfirmed
GUEST, unregistred user!
这是部分代码也是书上的代码小弟才学这个的哦有几个地方错了不知道怎么解决了谢谢大家帮一帮忙了代码后面是错!
procedure TForm2.Timer1Timer(Sender: TObject);
var
foldx,foldy:integer;
full:tbitmap;
fc:tcanvas;
dc:hdc;
begin
timer1.Enabled :=false;
full:=tbitmap.Create;
full.Width :=screen.Width;
full.Height :=screen.Height;
dc:=getdc(0);
fc:=tcanvas.Create ;
fc.handle:=dc;
full.Canvas.CopyRect(rect(0,0,screen.Width,screen.Height),fc,rect(0,0,screen.Width,screen.Height ));
fc.Free;
releasedc(0,dc);
image1.Picture.Bitmap:=full;
image1.Width:=full.Width ;
image1.Height:=full.Height ;
full.Free;
form2.WindowState:=wsmaximized;
form2.Show;
messagebeep(1);
foldx:=-1;
foldy:=-1;
image1.Canvas.Pen.Mode:=pmnot;
image1.Canvas.Pen.Color:=clblack;
image1.Canvas.Brush.Style:=bsclear;
flag:=true;
end;
procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
x1,x2,y1,y2,foldx,foldy:integer;
width,height,oldx,oldy:integer;
n:tbitmap;
begin
if trace=false then
begin
flag:=false;
with image1.Canvas do
begin
moveto(foldx,0);
lineto(foldx,screen.Height);
moveto(0,foldy);
lineto(screen.Width,foldy);
end;
x1:=x;
y1:=y;
oldx:=x;
oldy:=y;
trace:=true;
image1.Canvas.Pen.Mode:=pmnot;
image1.Canvas.Pen.Color :=clblack;
image1.Canvas.Brush.Style :=bsclear;
end
else
begin
x2:=x;
y2:=y;
trace:=false;
image1.Canvas.Rectangle(x1,y1,oldx,oldy);
width:=abs(x2-x1);
height:=abs(y2-y1);
form1.Image1.width:=width;
form1.Image1.height:=height;
n:=tbitmap.Create;
n.width:=width;
n.height:=height;
n.Canvas.CopyRect(rect(0,0,width,height),form2.Canvas,Rect(x1,y1,x2,y2));
form1.image1.picture.bitmap:=n;
n.Free;
form2.Hide;
form2.Show;
end;
end;
procedure TForm2.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var x1,y1,foldx,foldy,oldx,oldy:integer;
begin
if trace=true then
begin
with image1.Canvas do
begin
rectangle(x1,y1,oldx,oldy);
rectangle(x1,y1,x,y);
oldx:=x;
oldy:=y;
end;
end
else if flag=true then
begin
with image1.Canvas do
begin
moveto(foldx,0);
lineto(foldx,screen.Height);
moveto(0,foldy);
lineto(screen.Width,foldy);
moveto(x,0);
lineto(x,screen.Height);
moveto(0,y);
lineto(screen.Width,y);
foldx:=x;
foldy:=y;
end;
end;
end;
出错的地方是:undeclared identifier:'flag'
undeclared identifier:'trace'
我不知道这两 个是做什么用的我要怎么做才可以啊
procedure TForm2.Timer1Timer(Sender: TObject);
var
foldx,foldy:integer;
full:tbitmap;
fc:tcanvas;
dc:hdc;
begin
timer1.Enabled :=false;
full:=tbitmap.Create;
full.Width :=screen.Width;
full.Height :=screen.Height;
dc:=getdc(0);
fc:=tcanvas.Create ;
fc.handle:=dc;
full.Canvas.CopyRect(rect(0,0,screen.Width,screen.Height),fc,rect(0,0,screen.Width,screen.Height ));
fc.Free;
releasedc(0,dc);
image1.Picture.Bitmap:=full;
image1.Width:=full.Width ;
image1.Height:=full.Height ;
full.Free;
form2.WindowState:=wsmaximized;
form2.Show;
messagebeep(1);
foldx:=-1;
foldy:=-1;
image1.Canvas.Pen.Mode:=pmnot;
image1.Canvas.Pen.Color:=clblack;
image1.Canvas.Brush.Style:=bsclear;
flag:=true;
end;
procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
x1,x2,y1,y2,foldx,foldy:integer;
width,height,oldx,oldy:integer;
n:tbitmap;
begin
if trace=false then
begin
flag:=false;
with image1.Canvas do
begin
moveto(foldx,0);
lineto(foldx,screen.Height);
moveto(0,foldy);
lineto(screen.Width,foldy);
end;
x1:=x;
y1:=y;
oldx:=x;
oldy:=y;
trace:=true;
image1.Canvas.Pen.Mode:=pmnot;
image1.Canvas.Pen.Color :=clblack;
image1.Canvas.Brush.Style :=bsclear;
end
else
begin
x2:=x;
y2:=y;
trace:=false;
image1.Canvas.Rectangle(x1,y1,oldx,oldy);
width:=abs(x2-x1);
height:=abs(y2-y1);
form1.Image1.width:=width;
form1.Image1.height:=height;
n:=tbitmap.Create;
n.width:=width;
n.height:=height;
n.Canvas.CopyRect(rect(0,0,width,height),form2.Canvas,Rect(x1,y1,x2,y2));
form1.image1.picture.bitmap:=n;
n.Free;
form2.Hide;
form2.Show;
end;
end;
procedure TForm2.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var x1,y1,foldx,foldy,oldx,oldy:integer;
begin
if trace=true then
begin
with image1.Canvas do
begin
rectangle(x1,y1,oldx,oldy);
rectangle(x1,y1,x,y);
oldx:=x;
oldy:=y;
end;
end
else if flag=true then
begin
with image1.Canvas do
begin
moveto(foldx,0);
lineto(foldx,screen.Height);
moveto(0,foldy);
lineto(screen.Width,foldy);
moveto(x,0);
lineto(x,screen.Height);
moveto(0,y);
lineto(screen.Width,y);
foldx:=x;
foldy:=y;
end;
end;
end;
出错的地方是:undeclared identifier:'flag'
undeclared identifier:'trace'
我不知道这两 个是做什么用的我要怎么做才可以啊