XE7 Dialog Box methods support anonymous methods to handle their closing
At today's RAD Studio, Dephi and C++Builder First Look Webinar (September 4 - 6am, 11am and 5pm PDT) several attendees asked questions about how to handle "blocking dialogs" on mobile devices. New in XE7 is support for an additional parameter to support handling the close of the dialog. This new parameter is documented in the "What's new in XE7 Dialog Box methods" document on the Embarcadero DocWiki.
Here is the text from that part of the What's new in XE7 page.
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, <ACloseDialogProc>. 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. For more information about anonymous methods, see:
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.
ShowMessage also gained support for Android in XE7, and calls to ShowMessage are blocking on desktop platforms and non-blocking on mobile platforms. However, ShowMessage does not provide any new parameter to handle its closing. If you need to execute code after the dialog box that ShowMessage shows closes, use MessageDlg instead of ShowMessage.
Samples are available for Object Pascal and C++
You can find updated examples for MessageDlg in the RAD Studio XE7 Source forge repository. Here are the links for the same programs in XE6 and XE7. If you compare the code you'll see what you need to add for the additional parameter using anonymous methods.
Object Pascal and C++ examples in RAD Studio SourceForge repo:
When you compare the sample code you need to add for MessageDlg for XE7, here is what you will see.
Please login first in order for you to submit comments
- Page :