关闭程序出现“runtime error 216 at xxxxxxx"的错误提示怎么回事?

taoran12 2010-11-18 11:14:38
我用delphi写的程序,只要我进行下面的操作后,关闭程序就会出现标题那样的错误提示,进行其他操作就不会。怎么回事啊?
   begin
with PaintBox1.Canvas do
begin
Pen.Color := clGreen;
Pen.Style := psSolid;
Pen.Mode := pmCopy;
Rectangle(Rect1);
end;
PaintBox1.Canvas.Pen.Color := clblue;
Paintbox1.Canvas.Pen.Mode:=pmXor;
List:=TList<Integer>.Create;
for i := xyPoint1.Count - 1 downto 0 do
if (xyPoint1[i].x > Point1[1].x) and (xyPoint1[i].x < x) and
(xyPoint1[i].y < y) and (xyPoint1[i].y > Point1[1].y) then
begin
Listdata1.Delete(i);
List.Add(i);
drawcross(xyPoint1[i].x,xypoint1[i].Y);
end;
if List.Count>0 then
for i:=0 downto List.Count-1 do xyPoint1.delete(List.Items[i]);
paintbox1.Canvas.Pen.Color:=clGreen; //删除方框
paintbox1.Canvas.Rectangle(Rect1);
List.Clear;
end;
end;

其中xypoint1和Listdata1都是TLIst的对象
...全文
837 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
taoran12 2011-05-08
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 xuzheng629 的回复:]
出现同样的问题
[/Quote]

用7楼得办法可以解决,如果你能找到出错的地方当然更好了
xuzheng629 2011-04-24
  • 打赏
  • 举报
回复
出现同样的问题
taoran12 2010-11-28
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 n4ry 的回复:]
这个如果控件和代码太多不想找也是没什么问题的,这是由于DELPHI的异常机制引起的,挂一个SEH应该就可以解决了,在你的DPR工程文件加上这个函数

Delphi(Pascal) code

procedure Halt0;
begin
Halt;
end;



然后在下面的begin...end里写上下面的汇编

Delphi(Pascal) code

as……
[/Quote]

用了你的方法异常解决了多谢,不过我还是没找到异常在哪里
n4ry 2010-11-27
  • 打赏
  • 举报
回复
这个如果控件和代码太多不想找也是没什么问题的,这是由于DELPHI的异常机制引起的,挂一个SEH应该就可以解决了,在你的DPR工程文件加上这个函数

procedure Halt0;
begin
Halt;
end;


然后在下面的begin...end里写上下面的汇编

asm
xor edx, edx
push ebp
push OFFSET @@safecode
push dword ptr fs:[edx]
mov fs:[edx],esp

call Halt0
jmp @@exit;

@@safecode:
call Halt0;

@@exit:
end;
Oraclers 2010-11-19
  • 打赏
  • 举报
回复
可能与TList对象建立后未释放有关。
taoran12 2010-11-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 oraclers 的回复:]
可能与TList对象建立后未释放有关。
[/Quote]
能说的具体点吗?是不是执行Listdata1.Delete(i)还要释放它占用的内存啊?
Oraclers 2010-11-19
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 taoran12 的回复:]
引用 3 楼 kye_jufei 的回复:
下面的語句在create後有安全free嗎。。。

Delphi(Pascal) code
List:=TList <Integer>.Create;

在程序结束时TLIst对象要手动释放吗?
[/Quote]
如果是局部变量,在过程或涵数结束时释放,如果全局变量在程序关闭时需要释放。
List.Free;
taoran12 2010-11-19
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 kye_jufei 的回复:]
下面的語句在create後有安全free嗎。。。

Delphi(Pascal) code
List:=TList <Integer>.Create;
[/Quote]
在程序结束时TLIst对象要手动释放吗?
风之谷 2010-11-19
  • 打赏
  • 举报
回复
检查 你的timer 线程 循环 中是否在关闭时还在继续,可能是由于资源释放引起的
kye_jufei 2010-11-19
  • 打赏
  • 举报
回复
下面的語句在create後有安全free嗎。。。
List:=TList<Integer>.Create;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧