Not really sure what I'm doing wrong but I am in the middle of putting together an android app using Delphi XE8.
At a certain point when a a message dialog appears and user selects YES I want it to call a button OnClick event which is already in the app.
The button loads the camera when pressed.
I have done this thinking it is correct but it doesn't work:
if MessageDlg ('Do you wish to continue?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo],0) = mrYes then
begin
TakeImageClick(self);
end;
Stepping through the code I do not get any errors but it just completely skips over the button click event.
The button is a TSpeedButton.
Any help would be much appreciated. Thanks,
Please read Embarcadero's documentation.
If a call to MessageDlg does not include the ACloseDialogProc parameter, the call is blocking on all platforms; that is, MessageDlg does not return until the dialog box closes. Android does not support these blocking calls, you can only use MessageDlg on Android if you provide the ACloseDialogProc parameter.
This functionality was added in XE7:
Dialog Box Methods Support Anonymous Methods to Handle Their Closing
In XE6, calls to dialog box methods (InputBox, InputQuery, MessageDlg, ShowMessage) were always blocking. Any code after a call to one of these methods is not executed until the dialog box closes. Android does not allow blocking dialog boxes, so you could not use these methods on Android.
On XE7, InputBox, InputQuery, and MessageDlg support a new optional parameter, . Calls that include this new parameter work on all platforms, including Android. This new optional parameter allows you to provide an anonymous method that is called when the dialog box closes. When you call these methods using this new parameter, your call is blocking in desktop platforms and non-blocking in mobile platforms. If you need to execute code after your dialog box closes, use this new parameter to ensure that your application works as expected on all supported platforms.
If you call InputBox, InputQuery, or MessageDlg and you do not provide an anonymous method on your call, these methods behave as they used to behave in XE6: calls are blocking on all platforms, including iOS, and Android is not supported.
For example:
MessageDlg('Do you wish to continue?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0,
procedure(const AResult: TModalResult)
begin
if AResult = mrYes then
TakeImageClick(Self);
end
);