Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Callback with c++
#4
(04-23-2021, 01:43 PM)kpenzkofer Wrote: This is a delphi Example but i can't figue out how to do it in c++

The 2nd parameter of RegisterCallback() is a TIWCallBackFunction. All online references I can find (I don't have IntraWeb myself) show TIWCallBackFunction is a "procedure(TStringList) of object", which means your original C++ should have worked fine. However, since the "working" Delphi example is using an anonymous procedure for the callback, that means TIWCallBackFunction must have been changed at some point into a "reference to procedure(TStrings)" instead.

See How to Handle Delphi Anonymous Methods in C++ in Delphi's documentation.

If you are using one of the CLang-based C++ compilers, try using a lambda for the callback, eg:

Code:
void __fastcall TfrmMain::headerRightButtonClick(TObject *Sender)
{
    WebApplication->RegisterCallBack(_D("MyCallback"),
        [](TStrings *slList){ ... }
    );
}

Otherwise, if you are using the classic Borland compiler, try creating a custom functor instead, eg:

Code:
class TMyCallbackRef : public TCppInterfacedObject<TIWCallBackFunction>
{
public:
    INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);

    void __fastcall Invoke(TStrings *slList) {
        ...
    }
};

void __fastcall TfrmMain::headerRightButtonClick(TObject *Sender)
{
    WebApplication->RegisterCallBack(_D("MyCallback"),
        _di_TIWCallBackFunction(new TMyCallbackRef())
    );
}

Reply


Messages In This Thread
Callback with c++ - by kpenzkofer - 04-23-2021, 07:54 AM
RE: Callback with c++ - by Jose Nilton Pace - 04-23-2021, 12:19 PM
RE: Callback with c++ - by kpenzkofer - 04-23-2021, 01:43 PM
RE: Callback with c++ - by rlebeau - 04-23-2021, 03:34 PM
RE: Callback with c++ - by kpenzkofer - 04-23-2021, 03:52 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)