Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: IFMXDialogServiceAsync



Permlink Replies: 2 - Last Post: Feb 12, 2018 10:49 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Tony Thompson

Posts: 5
Registered: 12/14/02
IFMXDialogServiceAsync
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 9, 2018 6:33 PM
_di_IFMXDialogServiceAsync ADialogAsync;
if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXDialogServiceAsync), &ADialogAsync))
{
ADialogAsync->MessageDialogAsync("Are you sure?", TMsgDlgType::mtConfirmation, mbYesNo, TMsgDlgBtn::mbNo, 0,
[](System::TObject* Sender, const System::Uitypes::TModalResult AResult)
{
if (AResult == mrYes)
{
// Delete thing
}
});
}

Could someone please explain why this fails to compile?

[bcc64 Error] systobj.h(602): 'Invoke' marked 'override' but does not override any member functions
[bcc64 Hint] systobj.h(614): in instantiation of template class 'System::InvokeWrapper<Fmx::Dialogs::TInputCloseDialogProc, <lambda at Forms\fMain.cpp:246:9>, void (<lambda at Forms\fMain.cpp:246:9>::*)(System::TObject *, int) const>' requested here
[bcc64 Hint] fMain.cpp(246): in instantiation of function template specialization 'System::DelphiInterface<Fmx::Dialogs::TInputCloseDialogProc>::DelphiInterface<<lambda at Forms\fMain.cpp:246:9> >' requested here
[bcc64 Error] systobj.h(614): allocating an object of abstract class type 'InvokeWrapper<Fmx::Dialogs::TInputCloseDialogProc, TNonRef, decltype(&TNonRef::operator())>'
[bcc64 Hint] fMain.cpp(246): in instantiation of function template specialization 'System::DelphiInterface<Fmx::Dialogs::TInputCloseDialogProc>::DelphiInterface<<lambda at Forms\fMain.cpp:246:9> >' requested here
[bcc64 Hint] FMX.Dialogs.hpp(165): unimplemented pure virtual method 'Invoke' in 'InvokeWrapper'
Tony Thompson

Posts: 5
Registered: 12/14/02
Re: IFMXDialogServiceAsync
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 9, 2018 6:46 PM   in response to: Tony Thompson in response to: Tony Thompson
Tony Thompson wrote:
_di_IFMXDialogServiceAsync ADialogAsync;
if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXDialogServiceAsync), &ADialogAsync))
{
ADialogAsync->MessageDialogAsync("Are you sure?", TMsgDlgType::mtConfirmation, mbYesNo, TMsgDlgBtn::mbNo, 0,
[](System::TObject* Sender, const System::Uitypes::TModalResult AResult)
{
if (AResult == mrYes)
{
// Delete thing
}
});
}

Could someone please explain why this fails to compile?

[bcc64 Error] systobj.h(602): 'Invoke' marked 'override' but does not override any member functions
[bcc64 Hint] systobj.h(614): in instantiation of template class 'System::InvokeWrapper<Fmx::Dialogs::TInputCloseDialogProc, <lambda at Forms\fMain.cpp:246:9>, void (<lambda at Forms\fMain.cpp:246:9>::*)(System::TObject *, int) const>' requested here
[bcc64 Hint] fMain.cpp(246): in instantiation of function template specialization 'System::DelphiInterface<Fmx::Dialogs::TInputCloseDialogProc>::DelphiInterface<<lambda at Forms\fMain.cpp:246:9> >' requested here
[bcc64 Error] systobj.h(614): allocating an object of abstract class type 'InvokeWrapper<Fmx::Dialogs::TInputCloseDialogProc, TNonRef, decltype(&TNonRef::operator())>'
[bcc64 Hint] fMain.cpp(246): in instantiation of function template specialization 'System::DelphiInterface<Fmx::Dialogs::TInputCloseDialogProc>::DelphiInterface<<lambda at Forms\fMain.cpp:246:9> >' requested here
[bcc64 Hint] FMX.Dialogs.hpp(165): unimplemented pure virtual method 'Invoke' in 'InvokeWrapper'

It doesn't take Sender parameter. Doh!
[](System::TObject* Sender, const System::Uitypes::TModalResult AResult) => [](const System::Uitypes::TModalResult AResult)
Remy Lebeau (Te...


Posts: 9,448
Registered: 12/23/01
Re: IFMXDialogServiceAsync
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 12, 2018 10:49 AM   in response to: Tony Thompson in response to: Tony Thompson
Tony Thompson wrote:

Could someone please explain why this fails to compile?

According to the error messages, the compiler is chosing to invoke the
TInputCloseDialogProc overloaded version of MessageDialogAsync(). Your
lambda doesn't match what that overload is expecting - there is no
'Sender' parameter in the callback procedure, but your lambda has one.
Try removing that parameter:

ADialogAsync->MessageDialogAsync(_D("Are you sure?"),
    TMsgDlgType::mtConfirmation, mbYesNo, TMsgDlgBtn::mbNo, 0,
    [](const System::Uitypes::TModalResult AResult)
    {
        if (AResult == mrYes)
        {
            // Delete thing
        }
    }
);


The way your lambda is originally declared, you are expecting the
compiler to invoke the TInputCloseDialogEvent overloaded version of
MessageDialogAsync() instead, which does have a 'Sender' parameter in
the callback. In that case, MessageDialogAsync() has an additional
AContext parameter that is NULL by default. If you want to call this
overloaded version (which is not necessary in your example), try
passing that parameter explicitly so the compiler knows which overload
it should be calling:

ADialogAsync->MessageDialogAsync(_D("Are you sure?"),
    TMsgDlgType::mtConfirmation, mbYesNo, TMsgDlgBtn::mbNo, 0,
    [](System::TObject *Sender, System::Uitypes::TModalResult AResult)
    {
        if (AResult == mrYes)
        {
            // Delete thing
        }
    },
    nullptr // <-- or whatever TObject* to pass to the lambda...
);


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02