title: How to prevent Closing and Disposing of a winform in the FormClosing event?
body: <p>This question may seem like a duplicate, but I just ran in to this issue while I was testing my program and I am kind of confused as to how you solve it.</p>
  
  <p>I have a winform and it has a form closing event. In the event, I pop open a messagebox asking the user, "Are you sure you want to close the window?." If they pushed yes button, the application closes window and prevents it from being disposed as expected. So, I can open it again. However, if they pushed no button, it still closes the window, but now the window is disposed. So, when I try to open it again, it raised an exception, "Cannot access a disposed Object." When No button is pushed, I want the winform remain opened and not disposed.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>method PPMain.PPMain_FormClosing(sender: System.Object; e: System.Windows.Forms.FormClosingEventArgs);
  begin
         if MessageBox.Show('Are you sure you want to close the window?','PPMain',MessageBoxButtons.YesNo) = DialogResult.Yes then
         begin
               e.Cancel := true; 
               Hide; 
         end
         else
               e.Cancel := false;
  end;
  </code></pre>
  
  <p>I thought since you have to set e.Cancel = true to close the window and tell it to hide, doing the opposite of that (e.Cancel=false and no hiding) will prevent the winform from closing and being disposed.</p>
  
  <p>How do you solve this?</p>
  
  <p>Thank in advance,</p>