c++builder-10.2-tokyo

Issue with creating event handlers for registered components


I have a package created in RAD Studio C++Builder 10.2 containing a number of new components. I register each component as follows (at the bottom of the .cpp file for a component):

namespace Tmbdstringgrid_component
{
    void __fastcall PACKAGE Register()
    {
         TComponentClass classes[1] = {__classid(TMBDStringGrid)};
         RegisterComponents(L"MyComponents", classes, 0);
    }
}

These components have new event handlers eg:

__property TNotifyEvent OnValueChange = {read=FOnValueChange, write=FOnValueChange};

After the package containing these components is installed, adding one of these components to a Form at design time, and then creating an event handler by double-clicking the event in the Object Inspector, I get the following:

void __fastcall TForm1::MBDNumEdit1ValueChange(TObject *param_0)

Instead of:

void __fastcall TForm1::MBDNumEdit1ValueChange(TObject *Sender)

Can anyone help? Why is it not displaying the correct names as defined in the event type, instead using param_0, param_1, etc?

I suspect it is something to do with how the component is being registered.


Solution

  • There is nothing wrong with your code. This is simply a known bug in C++Builder 10.2 and 10.3 when using the Clang compiler instead of the classic Borland compiler:

    RSP-15602: When using CLang compiler with imported OCX the parameter names are not correct for events

    RSP-21807: Wrong parameter names in events for C++ components (used in Clang projects): param_0 instead of Sender...

    RSP-28047: Wrong function header created for callbacks from an imported ActiveX Control

    Not sure whether or not this issue still exists in 10.4 and 11.0, but the tickets are still open.