Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: CBXE8 - MessageBox() YESNO buttons in Android ?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Oct 19, 2015 7:57 PM Last Post By: Remy Lebeau (Te...
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
CBXE8 - MessageBox() YESNO buttons in Android ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2015 2:07 AM
Embarcadero® C++Builder XE8 Version 22.0.19027.8951 and Indy 10.
Window 10 Pro x64, Version 10.0.10240
Android 4.1.2

QUESTIONS

1. I have an existing form running, and how to pop up a blocking dialog box with YES NO buttons in Android ?

Please advise.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: CBXE8 - MessageBox() YESNO buttons in Android ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2015 10:27 AM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
GAI wrote:

I have an existing form running, and how to pop up a blocking
dialog box with YES NO buttons in Android ?

You cannot display a blocking dialog, as Android does not support modal
dialogs. You need to use the overloaded version of MessageDlg() that has
an ACloseDialogProc parameter. When the dialog is dismissed, the specified
callback procedure is called with the result, then you can act accordingly.
This is clearly stated in Embarcadero's documentation:

Using FireMonkey Modal Dialog Boxes
http://docwiki.embarcadero.com/RADStudio/en/Using_FireMonkey_Modal_Dialog_Boxes

How to Handle Delphi Anonymous Methods in C++
http://docwiki.embarcadero.com/RADStudio/en/How_to_Handle_Delphi_Anonymous_Methods_in_C%2B%2B

The same applies to all modal dialogs on Android, including MessageDlg(),
TForm.ShowModal(), etc.

--
Remy Lebeau (TeamB)
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
Re: CBXE8 - MessageBox() YESNO buttons in Android ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2015 7:29 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy, with reference to the following link:

http://bcbjournal.org/forums/viewtopic.php?f=10&t=2546

I have replaced the QueryInterface() method:

From

HRESULT STDMETHODCALLTYPE QueryInterface (const GUID& riid, void** ppvObject) { return TInterfacedObject::QueryInterface (riid, ppvObject); }

To

HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void** ppvObject) { return TInterfacedObject::QueryInterface (riid, ppvObject); }

Otherwise, the compiler will report error at:

_di_TInputCloseDialogProc proc = new TMyMessageDlgCloseProc;

oMain.cpp(1130,45): error E1443: allocating an object of abstract class type 'TMyMessageDlgCloseProc'
c:\program files (x86)\embarcadero\studio\16.0\include\android\rtl\sysmac.h(327,38): error E3048: unimplemented pure virtual method 'QueryInterface' in 'TMyMessageDlgCloseProc''

SYSMAC.H
struct INTERFACE_UUID("00000000-0000-0000-C000-000000000046") IUnknown {
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void ** ppvObject) = 0; // Error highlighted this line.
virtual ULONG STDMETHODCALLTYPE AddRef() = 0;
virtual ULONG STDMETHODCALLTYPE Release() = 0;
};

Please advise
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: CBXE8 - MessageBox() YESNO buttons in Android ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2015 7:57 PM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
GAI wrote:

Remy, with reference to the following link:

http://bcbjournal.org/forums/viewtopic.php?f=10&t=2546

That is an old discussion with some outdated information.

I have replaced the QueryInterface() method:

A better solution would be to use the INTFOBJECT_IMPL_IUNKNOWN() macro, as
described in the documentation:

Creating classes that support IUnknown
http://docwiki.embarcadero.com/RADStudio/en/Inheritance_and_Interfaces#Creating_classes_that_support_IUnknown

Let the C++ RTL override the virtual IUnknown methods and delegate them to
TInterfacedObject for you, so they always match correctly. For example:

class TMyMessageDlgCloseProc1 : public TInterfacedObject, public Fmx::Dialogs::TInputCloseDialogProc
{
public:
    INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
 
    void __fastcall Invoke(const TModalResult AResult)
    {
        ...
    }
};


Or:

class TMyMessageDlgCloseProc1 : public TCppInterfacedObject<Fmx::Dialogs::TInputCloseDialogProc>
{
public:
    void __fastcall Invoke(const TModalResult AResult)
    {
        ...
    }
};


--
Remy Lebeau (TeamB)
Mike Collins

Posts: 46
Registered: 9/23/05
Re: CBXE8 - MessageBox() YESNO buttons in Android ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2015 12:07 PM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
I battled for a while with this same problem.

In the end I created a wrapper function using a TLayout to hold my message text and action buttons.

My wrapper function allowed me to pass my title, caption and function pointers for each button.

I found this easier to work with than using Anonymous Methods in C++.

If you want more info, message me directly.

Regards

Mike C
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02