我想在构造函数中分配一个事件处理程序,如果它没有分配.因此,我想删除析构函数中最终分配的事件处理程序.我编写的代码如下,但无法编译.
constructor TSomeControl.Create(Panel: TPanel); begin inherited Create; FPanel := Panel; if not Assigned(FPanel.OnResize) then FPanel.OnResize := HandlePanelResize; end; destructor TSomeControl.Destroy; begin if @FPanel.OnResize = @HandlePanelResize then // [dcc32 Error] E2036 Variable required FPanel.OnResize := nil; FPanel := nil; inherited; end;