title: Delphi - Correctly displaying a Message Dialog in FireMonkey and returning the Modal Result
body: <p>I have a VCL application that I am porting to FireMonkey. One of the things that I ran into is that <code>MessageDlg(...)</code> is deprecated in FireMonkey. On digging a bit further, I understand that I have to use the <code>FMX.DialogService.MessageDialog</code> method. So I created a function to display a dialog:</p>
  
  <pre><code>function TfMain.GetDeleteConfirmation(AMessage: String): String;
  var
    lResult: String;
  begin
    lResult:='';
    TDialogService.PreferredMode:=TDialogService.TPreferredMode.Platform;
    TDialogService.MessageDialog(AMessage, TMsgDlgType.mtConfirmation,
      [ TMsgDlgBtn.mbYes, TMsgDlgBtn.mbCancel ], TMsgDlgBtn.mbCancel, 0,
      procedure(const AResult: TModalResult)
      begin
        case AResult of
          mrYes:    lResult:='Y';
          mrCancel: lResult:='C';
        end;
      end);
  
    Result:=lResult;
  end;
  </code></pre>
  
  <p>I don't think that I am doing this right as I am not sure I can set a local variable inside an anonymous method, but it compiles nevertheless. </p>
  
  <p>I call it like so:</p>
  
  <pre><code>  if GetDeleteConfirmation('Are you sure you want to delete this entry?')&lt;&gt;'Y' then
      exit;
  </code></pre>
  
  <p>When I run it, the message dialog shown is this:</p>
  
  <p><a href="https://i.stack.imgur.com/cQN7v.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cQN7v.png" alt="enter image description here"></a></p>
  
  <p>It does not show the 2 buttons (Yes, Cancel). Could someone please help me get this right - i.e. correctly show the message dialog with the 2 buttons and send the modal result of the message dialog back as the Result of the function.</p>
  
  <p>I am using Delphi 10.1 Berlin Update 2.</p>
  
  <p>Many thanks in advance!</p>
  
  <p><strong>EDIT 20170320:</strong> I corrected my code on the basis of the correct answer by @LURD below and am including it here for completeness:</p>
  
  <pre><code>function TfMain.GetDeleteConfirmation(AMessage: String): String;
  var
    lResultStr: String;
  begin
    lResultStr:='';
    TDialogService.PreferredMode:=TDialogService.TPreferredMode.Platform;
    TDialogService.MessageDialog(AMessage, TMsgDlgType.mtConfirmation,
      FMX.Dialogs.mbYesNo, TMsgDlgBtn.mbNo, 0,
      procedure(const AResult: TModalResult)
      begin
        case AResult of
          mrYes: lResultStr:='Y';
          mrNo:  lResultStr:='N';
        end;
      end);
  
    Result:=lResultStr;
  end;
  </code></pre>