我编译了一段简单的画几个圆的程序:
procedure TForm1.Button1Click(Sender: TObject);
var
g1,g2,h1,h2,f:Double;
begin
f:=12;
g1:=trunc(160+f-8);
g2:=trunc(g1-17);
h1:=trunc(160-f+8);
h2:=trunc(h1+17);
Canvas.Pen.Width:=2;
Canvas.Pen.Color:=clRed;
Canvas.Brush.Color:=clRed;
Canvas.Brush.Style := bsBDiagonal;
Canvas.Ellipse(153,g2,170,g1);
Canvas.Ellipse(216,h1,233,h2);
Canvas.Ellipse(279,g2,296,g1);
Canvas.Ellipse(342,h1,359,h2);
Canvas.Ellipse(405,g2,422,g1);
Canvas.Ellipse(468,h1,485,h2);
end;end.
运行后出现下面 的错误提示:
[Error] Unit1.pas(39): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(40): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(41): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(42): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(43): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(44): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
帮帮看看什么原因,我试过将参数改为常数可以运行,但现在这样不能运行。
procedure TForm1.Button1Click(Sender: TObject);
var
g1,g2,h1,h2,f:Double;
begin
f:=12;
g1:=trunc(160+f-8);
g2:=trunc(g1-17);
h1:=trunc(160-f+8);
h2:=trunc(h1+17);
Canvas.Pen.Width:=2;
Canvas.Pen.Color:=clRed;
Canvas.Brush.Color:=clRed;
Canvas.Brush.Style := bsBDiagonal;
Canvas.Ellipse(153,g2,170,g1);
Canvas.Ellipse(216,h1,233,h2);
Canvas.Ellipse(279,g2,296,g1);
Canvas.Ellipse(342,h1,359,h2);
Canvas.Ellipse(405,g2,422,g1);
Canvas.Ellipse(468,h1,485,h2);
end;end.
运行后出现下面 的错误提示:
[Error] Unit1.pas(39): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(40): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(41): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(42): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(43): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Error] Unit1.pas(44): There is no overloaded version of 'Ellipse' that can be called with these arguments
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
帮帮看看什么原因,我试过将参数改为常数可以运行,但现在这样不能运行。
var
g1,g2,h1,h2,f:Double;
改为
var
g1,g2,h1,h2,f:Integer;
这里的X1、Y1、X2、Y2都是Integer类型,你定义个Double类型,当然不行了。