我的程序在退出时总是报告非法操作,我检查了了一下,问题出在下面这段显示子程序.找了好久没找到原因....急死了...大家帮帮忙.
delphi的非法提示:
Project hafumanPro.exe raised exception class EAccessViolation with message 'Access violation at address 00404418 in module 'HAFUMAN>EXE'.Read of address FFFFFFFF'.Process stopped.Use Step or Run to continue.
另外我这是一个显示2叉树的子程序,当最小化时,画好的树会消失,如果图的某一部分被遮住,那一部分也会小时,请问这种问题怎么解决.子程序:
procedure TForm1.Button8Click(Sender: TObject);
var
x,y,t,minwidth,maxheight,length,linewidth,i,j:integer;
a:array[1..50] of real;
tempx,tempy,tempe:real;
begin
image1.Invalidate;
image1.Update;
maxheight:=countmaxheight();
if maxheight>6 then
begin
showmessage('深度大于6,无法显示');
exit;
end
else
begin
if (maxheight<>1) then
begin
tempx:=maxheight-1;
tempy:=ln(2);
tempe:=exp(tempx*tempy);
minwidth:=trunc(398/tempe-14.5);
length:=trunc(300 div (maxheight-1)-6);
a[maxheight-1]:=minwidth;
for i:=maxheight-2 downto 1 do
begin
if i=maxheight-2 then a[i]:=minwidth+8.5
else a[i]:=2*a[i+1]+6;
end;
end;
x:=(248+(248+401)) div 2;
y:=136+5+7;
tree.a[tree.n-1].x:=x;
tree.a[tree.n-1].y:=y;
canvas.Pen.Color:=clblue;
canvas.Ellipse(x-7,y-7,x+7,y+7);
for i:=1 to maxheight-1 do
begin
linewidth:=trunc(a[i]);
j:=0;
while(tree.a[j].weight<>0) do
begin
if(tree.a[j].height=i)then
begin
tree.a[tree.a[j].lchild].x:=tree.a[j].x-linewidth-5;
tree.a[tree.a[j].lchild].y:=tree.a[j].y+length+6;
tree.a[tree.a[j].rchild].x:=tree.a[j].x+linewidth+7;
tree.a[tree.a[j].rchild].y:=tree.a[j].y+length+6;
if(tree.a[j].lchild<>-1) then
begin
canvas.MoveTo(tree.a[j].x-7,tree.a[j].y);
canvas.LineTo(tree.a[j].x-7-linewidth+1,tree.a[j].y);
canvas.LineTo(tree.a[j].x-7-linewidth+1,tree.a[j].y+length-1);
canvas.Pen.Color:=clblue;
canvas.Ellipse(tree.a[tree.a[j].lchild].x-7,tree.a[tree.a[j].lchild].y-7,tree.a[tree.a[j].lchild].x+7,tree.a[tree.a[j].lchild].y+7);
end;
if(tree.a[j].rchild<>-1) then
begin
canvas.MoveTo(tree.a[j].x+7,tree.a[j].y);
canvas.LineTo(tree.a[j].x+7+linewidth-1,tree.a[j].y);
canvas.LineTo(tree.a[j].x+7+linewidth-1,tree.a[j].y+length-1);
canvas.Pen.Color:=clblue;
canvas.Ellipse(tree.a[tree.a[j].rchild].x-7,tree.a[tree.a[j].rchild].y-7,tree.a[tree.a[j].rchild].x+7,tree.a[tree.a[j].rchild].y+7);
end; end;
j:=j+1;
end;
end;
end;
delphi的非法提示:
Project hafumanPro.exe raised exception class EAccessViolation with message 'Access violation at address 00404418 in module 'HAFUMAN>EXE'.Read of address FFFFFFFF'.Process stopped.Use Step or Run to continue.
另外我这是一个显示2叉树的子程序,当最小化时,画好的树会消失,如果图的某一部分被遮住,那一部分也会小时,请问这种问题怎么解决.子程序:
procedure TForm1.Button8Click(Sender: TObject);
var
x,y,t,minwidth,maxheight,length,linewidth,i,j:integer;
a:array[1..50] of real;
tempx,tempy,tempe:real;
begin
image1.Invalidate;
image1.Update;
maxheight:=countmaxheight();
if maxheight>6 then
begin
showmessage('深度大于6,无法显示');
exit;
end
else
begin
if (maxheight<>1) then
begin
tempx:=maxheight-1;
tempy:=ln(2);
tempe:=exp(tempx*tempy);
minwidth:=trunc(398/tempe-14.5);
length:=trunc(300 div (maxheight-1)-6);
a[maxheight-1]:=minwidth;
for i:=maxheight-2 downto 1 do
begin
if i=maxheight-2 then a[i]:=minwidth+8.5
else a[i]:=2*a[i+1]+6;
end;
end;
x:=(248+(248+401)) div 2;
y:=136+5+7;
tree.a[tree.n-1].x:=x;
tree.a[tree.n-1].y:=y;
canvas.Pen.Color:=clblue;
canvas.Ellipse(x-7,y-7,x+7,y+7);
for i:=1 to maxheight-1 do
begin
linewidth:=trunc(a[i]);
j:=0;
while(tree.a[j].weight<>0) do
begin
if(tree.a[j].height=i)then
begin
tree.a[tree.a[j].lchild].x:=tree.a[j].x-linewidth-5;
tree.a[tree.a[j].lchild].y:=tree.a[j].y+length+6;
tree.a[tree.a[j].rchild].x:=tree.a[j].x+linewidth+7;
tree.a[tree.a[j].rchild].y:=tree.a[j].y+length+6;
if(tree.a[j].lchild<>-1) then
begin
canvas.MoveTo(tree.a[j].x-7,tree.a[j].y);
canvas.LineTo(tree.a[j].x-7-linewidth+1,tree.a[j].y);
canvas.LineTo(tree.a[j].x-7-linewidth+1,tree.a[j].y+length-1);
canvas.Pen.Color:=clblue;
canvas.Ellipse(tree.a[tree.a[j].lchild].x-7,tree.a[tree.a[j].lchild].y-7,tree.a[tree.a[j].lchild].x+7,tree.a[tree.a[j].lchild].y+7);
end;
if(tree.a[j].rchild<>-1) then
begin
canvas.MoveTo(tree.a[j].x+7,tree.a[j].y);
canvas.LineTo(tree.a[j].x+7+linewidth-1,tree.a[j].y);
canvas.LineTo(tree.a[j].x+7+linewidth-1,tree.a[j].y+length-1);
canvas.Pen.Color:=clblue;
canvas.Ellipse(tree.a[tree.a[j].rchild].x-7,tree.a[tree.a[j].rchild].y-7,tree.a[tree.a[j].rchild].x+7,tree.a[tree.a[j].rchild].y+7);
end; end;
j:=j+1;
end;
end;
end;
解决方案 »
- PageControl中Form输入操作会频繁出现失去焦点,edit等输入框无法输入
- sql-server后台的存储过程如何搬到前台执行?因为我想做单机版的程序,数据库是access.
- 服务器端已经生成考号,如何保证客户端得到连续的考号?
- 关于Excel保存问题?
- 关于DirectoryListBox的小问题
- 怎样自动获得EDIT中的汉字输入技术简拼,(我没有分了,所以只好用不着0分啦)——
- 本人最近要写一个类似控制台程序啊在dos模式下实现数据的操做,可是发现控制台类中确无法准确控制光标的位置啊,所以很难控制界面,请问给各
- formatdatetime('yyyy-mm-dd','2002-06-02'),为什么报错?
- 怎样下载类似 http://www.abc.cn/down.asp?name=computer.doc这样的文件,delphi代码怎样写.
- 在DELPHI中如何读取Excel 97 或2000工作表.急急急
- 请问在不同的数据库之间复制一个表如何实现
- 想在青岛找个工作!!!
在退出时报错
应该是退出时内存释放有问题