title: Delphi Android application - handle mrCancel with ShowModal form
body: <p>I am using <a href="http://blog.marcocantu.com/blog/xe5_anonymous_showmodal_android.html" rel="nofollow">Marco Cantu's ShowModal example</a> for Android applications. How do you handle for mrCancel</p>
  
  <p>here is the my code:</p>
  
  <pre><code>procedure TForm1.Button1Click(Sender: TObject);
  var
   Form2: TForm2;
  begin
   Form2 := TForm2.Create(nil);
   Form2.ShowModal(
      procedure(ModalResult: TModalResult)
      begin
        if ModalResult = mrOK then
        begin
         ShowMessage('OK');
         Form2.DisposeOf;
        end
       { else
        begin
         ShowMessage('Cancel'); 
         Form2.DisposeOf;
        end;}
        end);
  end;
  </code></pre>
  
  <p>How do I handle the mrCancel? If I have a form with controls the user must enter data in, i would like to give them the option to cancel out of the form and return to the main form. </p>
  
  <p>I should note that I assigned the modalresult to mrCancel for the cancel button, just like i did mrOK for the OK button on the secondary form.  The ok button works fine, but if i click the cancel button, the app does nothing and makes it so i cant click the OK button again.</p>
  
  <p>I would have assumed I could have done the following</p>
  
  <pre><code>var
   Form2: TForm2;
  begin
   Form2 := TForm2.Create(nil);
   Form2.ShowModal(
      procedure(ModalResult: TModalResult)
      begin
        if ModalResult = mrOK then
        begin
         ShowMessage('OK');
         Form2.DisposeOf;
        end
        end);
  end;
  </code></pre>
  
  <p>and i should have been able to assign mrCancel to the modalresult property of the cancel button - but it does not work</p>