Embarcadero has created a new non blocking MessageDlg() function in Delphi XE7 and Appmethod Firemonkey to better support Android. The code does work on IOS, Windows, and OSX too. The new function takes an anonymous method as the last parameter and it gets executed when the user clicks one of the buttons. In Delphi XE5 and XE6 the function would block and would not execute code after the user clicked one of the buttons from the MessageDlg(). Here is the example MessageDlg() code from XE5 and XE6:
case MessageDlg('Do you want to press yes or no?', System.UITypes.TMsgDlgType.mtInformation,
[
System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo
], 0) of
{ Detect which button was pushed and show a different message }
mrYes:
begin
// pressed yes
end;
mrNo:
begin
// pressed no
Exit;
end;
end;
// code here would run after the button clicks
And here is the new code for Firemonkey XE7 with the anonymous method used:
MessageDlg('Do you want to press yes or no?', System.UITypes.TMsgDlgType.mtInformation,
[
System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo
], 0,
procedure(const AResult: TModalResult)
begin
case AResult of
{ Detect which button was pushed and show a different message }
mrYes:
begin
// pressed yes
end;
mrNo:
begin
// pressed no
end;
end;
end
);
// code here would get executed right away
Head over and check out the full documentation about the MessageDlg() function on the Embarcadero docwiki.