title: Delphi: Test event handler assignment
body: <p>I want to assign an event handler in constructor, if it does not have one assigned. Consequentially I want to remove the eventually assigned event handler in destructor. I wrote the code as follows, but cannot be compiled. </p>
  
  <pre><code>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;
  </code></pre>
  
  <p>How to test it properly? I know a solution is to use a variable to record, whether I have assigned <code>OnResize</code>. But I do not want this as solution.</p>