W
wk_knife
Unregistered / Unconfirmed
GUEST, unregistred user!
Marco Cantu在《Delphi5从入门到精通》中说“[blue]在处理对象某个时间的同时,不能
消除该对象,否则会引起一个异常[/blue]”
在Delphi的帮助中有如下一段话:
[red]Warning[/red]: [blue]Never explicitly free a component within one of its own event
handlers or free a component from the event handler of a
component it owns or contains. For example, don't free a button
in its OnClick event handler or free the form that owns the
button from the button's OnClick event[/blue].
在窗体中建立一个按纽,处理OnClick
事件时:
procedure TForm1.ButtonKeyPress(Sender:TObject,var Key:Char)
begin
if Key=#8 then
Sender.Free;
end;
未出现任何问题(当然一般没人会写这样的代码)
请各位富翁就KeyPress事件写一个可以引发异常的代码。
或者是Marco Cantu说错了,而帮助也并没有说会发生异常。
消除该对象,否则会引起一个异常[/blue]”
在Delphi的帮助中有如下一段话:
[red]Warning[/red]: [blue]Never explicitly free a component within one of its own event
handlers or free a component from the event handler of a
component it owns or contains. For example, don't free a button
in its OnClick event handler or free the form that owns the
button from the button's OnClick event[/blue].
在窗体中建立一个按纽,处理OnClick
事件时:
procedure TForm1.ButtonKeyPress(Sender:TObject,var Key:Char)
begin
if Key=#8 then
Sender.Free;
end;
未出现任何问题(当然一般没人会写这样的代码)
请各位富翁就KeyPress事件写一个可以引发异常的代码。
或者是Marco Cantu说错了,而帮助也并没有说会发生异常。