title: How to cleanly free a frame within a click event on a button on the frame?
body: <p>I used to able to do this using plain delphi buttons:</p>
  
  <p>In the First Frame I have (simplified)</p>
  
  <pre><code>procedure FirstFrame.ButtonClick(Sender: TObject)
  Begin
    if TButton(Sender).ModalResult = mrOK then
      ChildFrame.DoOKStuff
    else
      ChildFrame.DoCancelStuff;
    ChildFrame.Free;
  end;
  
  procedure FirstFrame.ShowFranme;
  begin
    ChildFrame := TFrameWithButtons.Create(Owner);
    ChildFrame.Parent := self;
    ChildFrame.OKButton.OnClick := ButtonClick;
    ChildFrame.CancelButton.OnClick := ButtonClick;
    ChildFrame.Visible := True;
  end;
  </code></pre>
  
  <p>In the Childframe I do nothing to process the button click... the button click is already set to return control to the First Frame.</p>
  
  <p>With some third Party buttons this occasionally causes an AV.
  I understand why - at some point in the 3rd party code processing returns to a now freed frame or button BUT the called code is in the first frame... Annoyingly it just works 99.99% of the time :)</p>
  
  <p>There is no Release procedure for frames.</p>
  
  <p>So my question is what is the correct way to handle this situation?</p>
  
  <p>Using both Delphi 6 and Delphi 2009.</p>